Jeremy Hylton : weblog : 2003-12-02

An Interpreter Prompt on the AST Branch

Tuesday, December 02, 2003

I made a little progress on the AST branch today: By fixing a few bugs and disabling use of sre on startup, I was able to bring up a normal interactive interpreter session. I don't have much time to work on Python, but it would be really great if the AST branch could be finished for Python 2.4.

I had been meaning to finish support for *varargs and **kwargs for months, but never found the time. It was all pretty simple, once I got back into the code. The only hitch was to add flags to the symbol table, which the assembler reads to set the code object flags for CO_VARARGS and CO_VARKEYWORDS.

Getting sre to compile correctly will be a good stress test now that there's minimal interactive support. It has several very large functions. At the moment, _parse() is failing at runtime.

Another good test would be to get to execute correctly, so that a make will finish without error.

One random idea for redesigning the AST has occurred to me a few times: Put the defaults argument values in a separate AST node that contains the FunctionDef node. Right now it's a real hassle to evaluate the defaults before pushing a new code block. If the defaults were the parent node, then the FunctionDef's children would all be executed in the function's environment.