[Python-Dev] Python and compilers

"Martin v. Löwis" martin at v.loewis.de
Wed Apr 7 00:31:06 CEST 2010


willian at ufpa.br wrote:
> First, thank you for all opnion. Each one was considered.
> I think the better question would be:
> I have to develop a project that involves compilers, and being a fan of
> Python, I thought about making a compiler for it (most basic idea involving
> Pythin and compilers). But I saw that I can use what I learned from
> compilers not only to create a compiler. What is the area of developing the
> Python interpreter that I could build my project, and please give me
> interesting ideas for the project.

I don't think the question is necessarily off-topic.

I can propose two projects, related to Python core:

- 2to3 pattern compiler: 2to3 currently uses an interpreter for pattern
  matching. It does "compile" the patterns into some intermediate form,
  however, that is actually interpreted with an interpreter written in
  Python (actually, it is self-interpreted). It might be interesting to
  compile the pattern into actual Python code, with the hope of it
  executing faster than it does now (and yes, I proposed a similar, but
  different GSoC topic also; the two approaches are orthogonal, though).

- IDLE code completion. Currently, IDLE has some form of code
  completion, which is fairly limited. It might be useful to produce a
  better code completion library, one that works more statically and
  less based on introspection. In particular, optimistic type inference
  might help (optimistic in the sense "if foo has a method .isalpha, it
  probably is a string). In code completion, exact type inference isn't
  necessary; giving a superset (i.e. a union type) might still be
  helpful.

In addition, to-python compilers may also be interesting in various HTML
templating languages, e.g. Django templating, Zope page templates, and
the like (although some of them already have compilers of some form on
their own).

HTH,
Martin


More information about the Python-Dev mailing list