int, float and string...

Kragen Sitaker kragen at pobox.com
Sat Jun 8 17:27:28 EDT 2002


"Mike C. Fletcher" <mcfletch at rogers.com> writes:
> See object.h in the Python source code.  Basically, Python objects 
> (PyObjects) are a C structure with book-keeping information (what is 
> your class/type, and your reference count) + the actual data of the 
> object.    Depending on the object type, that can be anywhere from 
> (minimum) 8 bytes to 8+x for every object.

PyObjects are generally allocated on the heap, which adds additional
overhead, typically about another 8 bytes per object.

> BTW, I'm not a C person, so I may be mis-calculating some of those 
> values, basic principle still applies: don't worry about differentiating 
> between int and float based on storage concerns save when using huge 
> numbers of them (preferably in Numeric arrays).

Even the built-in 'array' module might be an improvement.

> not mistaken).  Still, this is probably premature optimisation unless 
> you actually find yourself running out of memory.

Dunno if you've been watching, but Shagshag is building a text-search
engine that is running out of (gigabytes of) memory.




More information about the Python-list mailing list