PEP 318 decorators are not Decorators

Arien Malec arien_malec at yahoo.com.REMOVE
Thu Aug 12 22:56:34 EDT 2004


I've been following the decorator debate with some interest, and it's taken 
me a reasonably long time to understand what is meant by a decorator. One 
of the issues is that the Decorator pattern is more like a Unix pipe than 
it is what PEP 318 calls a decorator. The classic decorator is run-time, 
rather than define time, and is non-destructive to the base function. The 
PEP 318 decorator is define time and is a destructive change to the base 
function. For instance, the GoF book makes it clear that decorators may be 
added or removed without affecting the underlying class.

I personally think it's confusing to reuse the "Decorator" name for 
something that is not a classic decorator. I also agree with the many 
comments that the proposed syntax does not make it clear that what is going 
on is a destuctive transformation of the defined function.

Arien



More information about the Python-list mailing list