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

Terry Reedy tjreedy at udel.edu
Sat Apr 9 23:10:18 CEST 2011


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.

If the decorator return a wrapper instead of the original function, 
then, of course, the *wrapper* gets called with each call. Or a 
decorator can return a replacement that does not call the original function.

-- 
Terry Jan Reedy




More information about the Python-ideas mailing list