What If Python Replaced Elisp?
effbot at telia.com
Fri Mar 10 08:19:43 CET 2000
Neel Krishnaswami <neelk at brick.cswv.com> wrote:
> There are actually a whole lot of optimizations that could be done,
> but aren't, in the current Python interpreter.
> For example, in the following code:
> import operator
> lst = 
> for i in range(100):
> lst.append(i**2 + i**2)
> result = reduce(operator.add, lst)
> You can statically infer the type of result, the final size of lst,
> avoid actually allocating a range() object, eliminate the the
> typechecks that make sure that i has a __pow__ method, the bounds
> checks on the range object, do available expressions analysis on the
> i**2 to avoid calculating it twice, and probably a few more
> optimizations that I don't know about.
You're assuming that you know exactly what "range",
"reduce", and "operator.add" evaluates to.
but you don't, in today's Python.
More information about the Python-list