One Python 2.1 idea

rturpin at my-deja.com rturpin at my-deja.com
Mon Dec 25 18:43:46 CET 2000


In article <tTK16.73794$x6.34384327 at news2.rdc2.tx.home.com>,
  "Rainer Deyke" <root at rainerdeyke.com> 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.

Russell


Sent via Deja.com
http://www.deja.com/



More information about the Python-list mailing list