def __init__(self, path): import array array = array.array('b') fd = os.open(path, os.O_RDONLY) sz = os.fstat(fd).st_size fp = os.fdopen(fd, 'rb') array.fromfile(fp, sz) os.close(fd) addr, count = array.buffer_info() self.lm = libngram.Ngram_init_from_bin(cast(addr, POINTER(c_byte)))
result = [] for item in mysql_dict: if mysql_dict[item] == 1: result.append(item) def testb(b): length = max(max(b), len(b)) dest_list = [0 for i in xrange(length + 1)] for i in b: dest_list[i] += 1 result = [] for index, i in enumerate(dest_list): if i == 1: result.append(index) from bitmap import BitMap bm = BitMap(32) print bm.tostring() bm.set(21) print bm.tostring() from array import array array.fromfile() from cli import lock