[Python-ideas] AST Transformation Hooks for Domain Specific Languages

Arnaud Delobelle arnodel at gmail.com
Sat Apr 9 23:37:55 CEST 2011


On 9 Apr 2011, at 22:10, Terry Reedy wrote:

> On 4/9/2011 2:06 AM, Eric Snow wrote:
> 
>> My understanding is that the AST transformation is done at compile-time,
>> while the decorator happens at run-time.
> 
> Nope. Decorator call happens just after compilation, but before calls.
> A decorator could compile a new code object and replace the original.

I don't understand what you are saying.  A decorator call occurs just after the execution of the def statement it decorates, which is definitely at run-time.  And that's completely unrelated to compilation time.  In fact most module are executed many times between compilations.  And yes, a decorator can compile a new code object, but how is it relevant?

-- 
Arnaud




More information about the Python-ideas mailing list