Ints and performance (was Re: PEP0238 lament)

Tim Peters at
Fri Jul 27 07:15:13 CEST 2001

[Peter Hansen]
> 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.

Actually not close at all.  In, e.g.,

    k = i + j

we spend a lot more time fiddling with reference counts and memory
management than doing the arithmetic!  But we'll ignore that since you're
already happy <wink>.

> Would the number system unification imply that this integer
> optimization would be eliminated?

It all depends on the details of the implementation; hardware reality
doesn't change, and we're still implementing Python in C, so no matter how
uniform the user-visible *model* we would still need to make distinctions
under the covers.

BTW, Python got along fine for years without any integer optimizations at
all, but I agree that specialing-casing int + - and compares in the eval
loop was a clear net win (for which you can, IIRC, thank Fredrik Lundh).

More information about the Python-list mailing list