[Python-Dev] compiler optimizations: collecting ideas

Nick Coghlan ncoghlan at gmail.com
Fri Nov 14 17:42:47 CET 2008


Daniel Furrer wrote:
> Hello everybody,
> 
> As part of an advanced compiler design course at our university (ETH
> Zurich), we have to implement an optimization (or various thereof).
> I've spoken with a couple of people who are, like me, very fascinated by
> Python.
> So I would just like to ask if somebody has any ideas on what we could do?
> 
> Our constraints:
> - We are 4 persons, each willing to potentially spend around 4-6 full
> days of work.
> - We've been working on generating Control Flow Graphs, generating
> Static Single Assignment Form (inserting phi-nodes) and removing it
> again. We've also implemented techniques like constant folding, copy
> propagation, Common Subexpression Elimination etc.
> 
> We're looking for:
> - Hints as to which python compiler would be best to work on. (The
> official Python compiler package seems very nice to work with actually...)
> - If there are any requests in the area of optimization that we could
> have a look at
> 
> Any feedback would be highly appreciated as well as pointers to specific
> bugs in the tracker and other relevant discussions.

Some random (hopefully helpful) thoughts:
- the Python compiler package is a bit of a dead end (we dropped it for
Py3k because converting/maintaining two full compilers would have been a
lot of work and seemed somewhat redundant now that the AST can be
manipulated from Python code)
- 3.0's syntax is cleaner than that of 2.x (since some of the old
backward compatibility issues are gone), but 2.x is in more widespread
use (unsurprisingly, since 3.0 isn't even expected to be released until
next month)
- there is a branch in SVN where Thomas Lee (IIRC) is working on moving
some of the current optimisations from the bytecode generation phase
back to the AST generation phase.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------


More information about the Python-Dev mailing list