Most efficient way of storing 1024*1024 bits

Mike Meyer mwm at mired.org
Wed Nov 2 15:41:08 CET 2005


"Tor Erik Sønvisen" <tores at stud.cs.uit.no> writes:
> I need a time and space efficient way of storing up to 6 million bits. Time 
> efficency is more important then space efficency as I'm going to do searches 
> through the bit-set.

Six megabytes is pretty much nothing on a modern computer. I'd store
the things as a string of "0" and "1", and then use .find (or maybe
the in keyword) for doing the searches.

This doesn't work very well if you're going to mutate the string,
though.

        <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list