[Python-Dev] Recent experience with the _ast module

Collin Winter collinw at gmail.com
Sat Feb 17 19:16:13 CET 2007


On 2/17/07, "Martin v. Löwis" <martin at v.loewis.de> wrote:
> Collin Winter schrieb:
> > But Pass, Break, Continue and Ellipsis aren't in the same category as
> > Add, Mult, Div, etc.. The former stand alone
>
> That's not true. Pass, Break, Continue don't stand alone; they are
> members of the body sequence of some other statement (in particular
> for Break and Continue), you need some kind of loop around it.
>
> In any case, they are in the same category as they have no child
> nodes, which is a prerequisite for not creating objects. I can't
> see why the property "stand alone" should impact whether objects
> are created or not.

I phrased that poorly. If Pass, Break and Continue were made into
singleton instances, they wouldn't be able to be handled by the same
visitor dispatch routine as the other statement types. Taking
Demo/parser/unparse.py as an example, Unparser.dispatch would have to
change to handle Break, Pass and Continue specially from the others.
Changing the operator and context nodes to be singleton instances
involves just modifying the dispatch tables used by _BoolOp, _BinOp,
etc.

Collin Winter


More information about the Python-Dev mailing list