[Python-ideas] Proposal for new-style decorators
Steven D'Aprano
steve at pearwood.info
Tue Apr 26 20:08:18 CEST 2011
Christophe Schlick wrote:
> * Is the idea interesting enough to deserve consideration for possible
> inclusion in the language? If yes, should I transform this proposal
> into a PEP, or should there first be some pre-PEP discussion here (or
> maybe in python-dev)?
Decorators were one of the biggest successes in recent years, so we
would be foolish to dismiss the idea of simplifying them out of hand.
But I think you are doing yourself a disservice by referring to this
proposal as "new syntax". Normally when people talk about syntax, they
are referring to language syntax (i.e. a change to the Python
interpreter), and we're pretty conservative about adding new syntax.
It seems to me that you're talking about a new idiom for building
decorator functions, not new syntax.
I would suggest you also publish this decorator-builder recipe on
ActiveState's Python cookbook, and see if you get much interest there.
It might also help to post a link to your recipe to
python-list at python.org. You certainly should do those things before
going to python-dev.
> * Are there some pitfalls involved with the use of NSD that I haven't
> seen? Or are there additional desirable elements that could be easily
> included?
Have you timed the decorated function using new and old style? If you
decorator a function with (say) 5 arguments, is there any performance
hit to your NSD?
Do you have any tests for it? E.g. unit tests, regression tests? Your
code looks opaque and complicated to me, I would want to see a good test
suite before even considering using it in production code, let alone in
the standard library.
--
Steven
More information about the Python-ideas
mailing list