Compiler C or Python?

Michael Hudson mwh at python.net
Tue Sep 2 07:37:03 EDT 2003


jhf at hex.no (Jørgen Hermanrud Fjeld) writes:

> On Tue, Aug 26, 2003 at 04:33:17PM -0500, Jeff Epler wrote:
> > 4. It's possible to write code so that __import__ uses compiler.compile
> > instead of the written-in-C compiler, but I don't have this code handy. 
> > Also, a test suite is needed, and presumably a written-in-C implementation
> > as well. (option 2: make the compiler.compile interface the standard
> > compiler, and let the builtin compiler support a Python subset
> > sufficient to bootstrap the written-in-python compiler, or arrange
> > to ship .pyc of the compiler package and completely get rid of the
> > written-in-C compiler)
> 
> Could you make an effort to locate that code, or give some suggestions to
> where I might locate it myself?
> 
> And in general, if should want to alter the Python compiler, should
> I start with the Python or C version?

Whichever's easiest :-)  This is usually the Python one.

A toy that might come in handy is an interactive mode (based on
code.InteractiveConsole) that compiles input with the customized
compiler.

> As far as I can see from your email the Python version is easier to
> modify, but why two compilers? Isn't that a lot to maintain?

The Lib/compiler/ package is pretty slow.  Also, making that the only
compiler might lead to irritating bootstrapping problems (which I now
see Jeff talked about...).

Cheers,
mwh

-- 
  Do I do everything in C++ and teach a course in advanced swearing?
         -- David Beazley at IPC8, on choosing a language for teaching




More information about the Python-list mailing list