some comments for Python 3000

Janne Sinkkonen janne at nnets.fi
Mon Aug 14 13:33:57 EDT 2000


"Rainer Deyke" <root at rainerdeyke.com> writes:

> Much worse, in fact.  In some cases, C outperforms Python by over 100:1.
> And memory usage is even worse.  In C, I can have a integer variable with
> range 0 to 255 in a single byte.  In Python, I need at least two objects
> (the integer and the string that holds the integer's name), both allocated
> on the stack (with whatever overhead this entails), both with four bytes
> reference count and four bytes pointer to the type object, plus the contents
> which are again at least four bytes each, plus one byte for each character
> in the variable name - and that isn't counting the extra storage needed for
> the entry in the dictionary (another eight bytes on average at least).
> That's worse than 64:1.  Even if the C version uses four bytes for the
> integer, it's 16:1.

If you have so many character objects that the above-mentioned memory
overhead is significant, there is usually some structure in the object
set which makes the use of strings, arrays (like Int8 of the Numeric
module), external data bases or some other compact representation
desirable. If not, then Python is not the right for the task. 

-- 
Janne
Hi! I'm a .signature virus! Please help me spread by copying me
into your .signature!



More information about the Python-list mailing list