Most efficient way of storing 1024*1024 bits

Alex Stapleton alexs at advfn.com
Fri Nov 4 05:54:27 EST 2005


On 4 Nov 2005, at 10:26, Ben Sizer wrote:

> Tom Anderson wrote:
>
>> 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.
>>
>
> I'd use 'or' rather than 'xor'. The or operator is more likely to  
> yield
> a '1' at the end of it, and a 1 is narrower than a 0, obviously making
> it more efficient to store.

<xahlee>
Typical gas guzzling, SUV driving american logic. A would obviously  
use more POWER and hence INCREASE GLOBAL WARMING leading to the  
ultimate DEATH of EVERYBODY you know and LOVE!
</xahlee>




More information about the Python-list mailing list