[Types-sig] Re: PEP 269

Jonathan Riehl jriehl@spaceship.com
Fri, 14 Sep 2001 16:43:58 -0500 (CDT)

On Fri, 14 Sep 2001, Martin von Loewis wrote: (In response to Samuele
> > - if it's purpose is to offer a framework for small languages
> > support, there are already modules around that support that
> > (SPARK, PLY ...), the only advantage of PEP 269 being speed
> > wrt to the pure python solutions, because of the use of the internal
> > CPython parser, OTOH the other solutions are more flexible...
> I agree. I'd like to see (or perhaps write myself) a proposal for
> adding one or two of these packages to the Python core (two are
> probably better, since there is no one-size-fits-all parser framework,
> and adding two avoids the impression that there is a single "blessed"
> parser).

I would like to note that integration with these other systems are in
the plans for my Basil project (http://wildideas.org/basil/).  I just felt
that a pgen integration would be better suited to the native code base
rather than copying the code over to another project and building it as an
extension module (which was a route being explored by Mobius Python.)

> > It should be considered that Jython does not contain a parser
> > similar to CPython one. Because of this jython does not offer parser
> > module support. So implementing the PEP for Jython would require
> > writing a Java or pure python equivalent of the CPython parser.

I am all for writing a pgen implementation in pure Python.  The reason I
am not going this route from the get go is to do what is easy before we do
what is less easy.  If, for example, a reference implementation of a
Python type system was to be adopted as standard, I would think that
making the new system easy to add to Jython would be a prerequisite.
Hence, we would need to develop a Jython parser that uses the grammar
from CPython.

> If the goal is to play with extensions to the Python grammar, I think
> this is less of an issue. Of course, anybody wanting to extend the C
> grammar could easily modify the Python interpreter itself.

> So I think I'm -1 on this PEP, on the basis that this is code bloat
> (i.e. new functionality used too rarely).

As stated in the PEP, one of the primary motiviations for the proposal is
to allow grammar extensions to be prototyped in Python (esp. optional
static typing.)  I would argue that making actual changes to CPython is
much more expensive than writing a front end in Python.  By adding a pgen
module to Python, I feel that we are not bloating Python so much as we are
exposing funtionality already built into Python.