One Python 2.1 idea

rturpin at rturpin at
Mon Dec 25 18:43:46 CET 2000

In article <tTK16.73794$x6.34384327 at>,
  "Rainer Deyke" <root at> wrote:
> _range = range
> ranges = []
> def my_range(*args):
>   r = _range(*args)
>   global ranges
>   ranges.append(r)
> __builtins__.range = my_range

Optimizing generated byte code for a language like Python
has to be done somewhat differently than for a language
like C++, which is designed so that types and names
resolve at compile time. There are a variety of strategies
for handling the code above. A simple one would flag for
recompilation any file where certain kinds of optimization
had been applied, when a built-in function were replaced.
Likely, there are better strategies.

Python presents other challenges besides the fact that
built-in functions can be changed on the fly. Fortunately,
almost all of these have been fodder, two or three times,
in the history of language processing. The dynamic and
flexible nature of Python is no excuse for slow execution.


Sent via

More information about the Python-list mailing list