[Compiler-sig] Assign nodes

Jeremy Hylton jeremy@zope.com
Wed, 17 Apr 2002 11:47:40 -0400


>>>>> "NN" == Neal Norwitz <neal@metaslash.com> writes:

  NN> Jeremy: In ast_for_augassign (astmodule.c), you are attempting
  NN> to find the assign type, but is it correct for <<= and >>= ?

  NN> Don't you need to add something like:

  NN> 	case '<':
  NN> 	        if (STR(n)[1] == '<')
  NN> 			return LShift;
  NN> 		fprintf(stderr, "invalid augassign: %s", STR(n));
  NN> 		return 0;

  NN> And the same for the '>'?

What is this checking for?

  NN> Also, do you want me to do some little cleanups and checkin?  Or
  NN> would you prefer to discuss here first?

Feel free to cleanup first and ask questions later.

  NN> Do you have any small pieces you want me to try to help with?

I was thinking it would be helpful for someone to work on the pickler
code.  I started, but didn't get very far.  I haven't given a lot of
thought about how to expose the AST objects to Python.  It seems like
making the PyObject's introduces a lot of overhead that doesn't serve
any purpose in the common case.

    (I'm assuming that the common case is the compiler using the AST
    internally to generate bytecode and then throwing it away.)

Pickling the AST from C and unpickling it from Python seems like a
simple way to share the AST without needing a PyObject-style
interface.

Two other possible projects are better memory management and better
error handling.  I decided to basically punt on that for now and
re-visit it after the astmodule is complete.  I suspect that an arena
style of allocation may be useful, where memory for the AST is
allocated from the arena and the arena is freed by one call when the
AST is no longer needed.

Jeremy