[Python-Dev] PEP 329: Treating Builtins as Constants inthe Standard Library

Samuele Pedroni pedronis at bluewin.ch
Tue Apr 20 06:49:34 EDT 2004

At 06:29 20.04.2004 -0400, Raymond Hettinger wrote:
> > he's proposing an hack that would speed up CPython and slow down
> > (because it would result in a no-op but OTOH he would like to remove
> > code
> > when some globals are bound to locals for speed reason. Of course
> > not nice too
> > but replacing a hack with another is just sort of a win. Honestly
> > are
> > probably
> > very convoluted ways to make this, in this form, a non no-op on Jython
> > too,
> > not that I would like to
> > implement them or that Raymond cared).
>Factually false on both counts.
>I do care. Jython was a key design consideration from the beginning.
>Guido and I specifically went over the non-CPython implications before
>the PEP was submitted.
>The no-op is automatic and makes bind_all equal to lambda *args, **kwds:
>0.  It is invoked only the first time a module is imported.   The time
>difference is unmeasurably miniscule.

from the PEP

The library contains code such as _len=len which is intended to create fast 
local references instead of slower global lookups. Though necessary for 
performance, these constructs clutter the code and are usually incomplete 
(missing many opportunities).

If the proposal is adopted, those constructs could be eliminated from the 
code base and at the same time improve upon their results in terms of 

if they are eliminated (_len = len), then CPython will win because of the 
binding at load time
and the fact that time is not lost at each function call  for binding them, 
Jython will loose something
because if they were there, there was likely a reason.

More information about the Python-Dev mailing list