Efficiency of using long integers to hold bitmaps

Jeff Melvaine jeffm at rivernet.com.au
Tue Jul 12 06:23:57 EDT 2005


Raymond,

Thanks for your answers, which even covered the question that I didn't ask 
but should have.

<code> "A Python list is not an array()\n" * 100 </code> :)

Jeff

"Raymond Hettinger" <python at rcn.com> wrote in message 
news:1121017410.949244.288220 at g44g2000cwa.googlegroups.com...
> [Jeff Melvaine]
>> I note that I can write expressions like "1 << 100" and the result is 
>> stored
>> as a long integer, which means it is stored as an integer of arbitrary
>> length.  I may need to use a large number of these, and am interested to
>> know whether the storage efficiency of long integers is in danger of
>> breaking my code if I use too many.  Would I do better to write a class 
>> that
>> defines bitwise operations on arrays of integers, each integer being 
>> assumed
>> to contain at most 32 bits?
>
>
> Both array() objects and long integers are equally space efficient.
> In contrast, a list of integers takes up a lot of space (the list is
> stored as an array of pointers to individual integer objects).
>
> Raymond
> 





More information about the Python-list mailing list