[Compiler-sig] AST observations

Jeremy Hylton jeremy@zope.com
Thu, 18 Apr 2002 14:53:48 -0400


Finally, I should say that I don't have any strong attachment to the
visitor code in the compiler package.  Nor do I have any strong
attachment to the AST it defines.  I've started over with python.asdl,
and I don't have any problems with starting over on a new visitor
structure.  Let's find the ideas that work best for all our
applications.  I'm probably going to want something visitor like
implemented in C for the builtin bytecode compiler; I don't have any
idea what that will look like yet.

Efficiency was a non-goal for compiler.visitor.  I didn't even
consider whether generating efficient Java code was possible.  (What
would be the point of writing in the subset of Python that can be
translated efficiently to Java? <wink>)

We're kindof stuck with compiler package as it exists now, since it's
a std part of 2.2.  But there's no reason it can't grow new classes
that provide new or improved functionality.

On the subject of what the right visitor style is, it looks like Eelco
and Joost Visser are doing interesting work in this area on the guide
pattern and visitor combinators, respectively.  (I don't have any idea
of the people are related, although the ideas are at some level :-).
I don't have links handy, but I a google search on name + visitor will
get you there.

Eric-- Feel free to contribute concrete patches that make the existing
visitor code faster.  I tried to speed it up too, once, and didn't
make much progress.  Much as you saw, I didn't see obvious changes
that made a big difference.

Jeremy