2011/9/15 Albert Zeyer <alb...@googlemail.com>:
> Hi list,
>
> I thought it would be nice in Python to allow some sort of meta coding
> (which goes far ahead of simple function descriptors).
>
> The most straight forward way would be to allow operations on the AST.
>
> I wrote a small patch for CPython 2.7.1 which, for each code object,
> adds the related AST of the statement to a new attribute `co_ast`.
>
> https://github.com/albertz/CPython/commit/2670e621458fd80311fc02897b698ea2a36d494b
>
> Some simple demonstration of what you can do with this:
>
> https://github.com/albertz/CPython/blob/astcompile_patch/test_co_ast.py
>
> I'm not sure wether the Python AST in this form is optimal for doing
> such things, though. Maybe another representation would be more
> efficient and result in simpler code for doing transformations.

It would be useful, but is a waste of memory is 99.99% of programs.



-- 
Regards,
Benjamin
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to