What If Python Replaced Elisp?

Johann Hibschman johann at physics.berkeley.edu
Fri Mar 10 08:59:24 CET 2000


Tim Peters writes:

> [Neel Krishnaswami]
>> 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.

> Actually not, you can't do any of that now!  You currently have no way to
> know that, e.g., some *other* module didn't import this one (let's call this
> one "neel"), and redirect neel.range and neel.reduce to some arbitrary
> functions of its own devious choosing.  Heck, the call to neel.range may
> even reach back in and change neel.lst to anything at all before the loop
> body is entered.  "i" may end up referring to an object whose __pow__ method
> sends email to Afghanistan; etc.

Well, surely you can generate some checks to make sure those objects
are bound to the builtin methods and then exectute the optimized code
if they are, while resorting to the "regular" version if someone has
done something strange, right?  It would bloat the byte-code files a
bit, though.

I mean, this isn't anything the Scheme compiler-writers haven't
already had to do.


-- 
Johann Hibschman                           johann at physics.berkeley.edu



More information about the Python-list mailing list