Ints and performance (was Re: PEP0238 lament)

Peter Hansen peter at engcorp.com
Thu Jul 26 19:44:00 EDT 2001


Guido van Rossum wrote:
> 
> I don't see when a unified number system would ever be less convenient
> than the current number system, *except* in the rare case where you
> are transliterating an algorithm from C that depends on integer size.
> Unsigned ints of n bits are easily emulated by taking all results
> modulo 2**n -- I do this now using Python long ints when I need to
> emulate unsigned C longs.
> 
> Using the new type/class unification in Python 2.2, you will be able
> to subtype the int or long types easily to create your own constrained
> types.

The interpreter currently has direct support for the most-used 
integer operations, thus ensuring that this type has performance 
reasonably close to the maximum feasible given the nature of 
virtual machines.

Would the number system unification imply that this integer optimization 
would be eliminated?  If true, wouldn't this impact Python's performance
so negatively that it would definitely get into the realm of 
"less convenient"?

(I'm definitely not in favour of optimization over functionality,
but this would go over the line, I think.)

-- 
----------------------
Peter Hansen, P.Eng.
peter at engcorp.com



More information about the Python-list mailing list