[Python-3000] compiler module

Thomas Lee tom at vector-seven.com
Fri Jan 11 05:38:13 CET 2008

Brett Cannon wrote:
> On Jan 10, 2008 8:39 AM, Joe Angell <joe.d.angell at gmail.com> wrote:
>> My apologies if this has been asked before, but are there any plans to
>> add the compiler module back in to py3k?  If so, any idea on a
>> timeline?  If help is needed I may be able to put in some time on
>> this.  I've already back ported some of the py3k grammar (function
>> parameter annotations) to python 2.5.1 so I can use this with the
>> compiler module, but I think it would be sweet to just use py3k
>> directly.
> As Guido said, it is not going back. But we would appreciate help in
> writing a function that takes Python's actual AST represesntation (as
> returned by compile()) and generated the proper bytecode from it.
Sorry, I should have been paying more attention to this thread:

I started on this a few months back at Neal's recommendation. I have a 
patch that is mostly working, but seems to be crashing out for a 
particular case (trying to compile functions, IIRC). I was never quite 
able to work out where it was going wrong. I'll upload my current patch 
to the tracker later tonight - I'd love some help trying to figure out 
why it's crashing out.

Using the patch it's possible to convert between the PyObject AST 
representation and the AST representation used internally by the 
compiler (thus it's possible to compile() an AST down to bytecode).

The patch is against current HEAD, not Py3k, but it should be a good 
starting point.


More information about the Python-3000 mailing list