Most efficient way of storing 1024*1024 bits
Tom Anderson
twic at urchin.earth.li
Thu Nov 3 11:11:49 EST 2005
On Wed, 2 Nov 2005, Dan Bishop wrote:
> Tor Erik Sønvisen wrote:
>
>> I need a time and space efficient way of storing up to 6 million bits.
>
> The most space-efficient way of storing bits is to use the bitwise
> operators on an array of bytes:
Actually, no, it's to xor all the bits together and store them in a single
boolean.
Getting them back out is kinda tricky though.
>> Time efficency is more important then space efficency
>
> In that case, you're better off simply using a list of bools.
Unlikely - the indexing is a bit simpler, but the cache hit rate is going
to go through the floor.
tom
--
power to the people and the beats
More information about the Python-list
mailing list