Skip to content Skip to sidebar Skip to footer

Create A List Like Object Using A Bitarray

I need to track a set of perhaps 10 million numbers in Python. (All numbers are between 0 and 2^32). I'll know before hand the max val of an integer, and, between 0 and max, betw

Solution 1:

bitarrays support an itersearch method that iterates over all positions where one bitarray occurs in another. Use that:

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

Post a Comment for "Create A List Like Object Using A Bitarray"