python - Create a list like object using a bitarray -


i need track set of perhaps 10 million numbers in python. (all numbers between 0 , 2^32). i'll know before hand max val of integer, and, between 0 , max, between 20-80% of values in set.

my current code uses built in set. way slow. far performance considered, best way bitarray (such https://pypi.python.org/pypi/bitarray/ ).

it's easy me use bitarray build class add(n) , remove(n) methods. don't know how support for n in bitarray_set:. think need use iterator or iterable, i'm not sure how that. possible? how?

bitarrays support itersearch method iterates on positions 1 bitarray occurs in another. use that:

def __iter__(self):     return self.bits.itersearch(bitarray([true])) 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -