[Python-Dev] Re: PEP 318: Decorators last before colon

Holger Krekel pyth at devel.trillke.net
Thu Apr 1 03:10:02 EST 2004

Bob Ippolito wrote:
> On Mar 31, 2004, at 3:37 PM, Holger Krekel wrote:
> >Specifically, in PyPy we use something like
> >
> >    def add_List_List(self, w_list1, w_list2):
> >        ...
> >    def add_Int_Int(self, w_list1, w_list2):
> >        ...
> >
> >and later on just one:
> >
> >    register_all(vars(), W_ListType)
> >
> >(which will register the methods to some multimethod dispatcher).  It's
> >a matter of taste i guess if using decorators - whatever syntax - at  
> >each
> >function definition would be more readable.
> Would you have even considered writing something as crazy as the  
> aforementioned example if decorators were already in Python?  I doubt  
> it.

Yes, we might have have used some decorator syntax.  But then again,
we also might use full Macros if they were available.  The question
(to me) is if there are enough use cases to warrant a new special 
decorator syntax.  

At least consider that Python's battery library only has ~10 
occurences of 'classmethod' and no 'staticmethod' at all.  

And let me add that IMO decorators generally make things harder to 
read because you have to wonder what magic takes place in those 
decorators.  IOW, i am not sure that seeing decorators occurring 
everywhere (because they become so convenient to write) will improve 
readability and debuggability of a python program. 

> >for example you could try to use the first line of the docstring
> >for it - maybe building on the typical way to document C-defined python
> >functions. e.g.:
> >
> >    "(some_type_signature) -> (some_return_type)"
> >
> >I am not saying straight away this is better but i doubt that the
> >only good solution to the above problem is to add new syntax.
> Mangling *doc* strings is really stupid and is not even an option,  
> IMHO.  The only reason people do this is because we don't have a  
> decorator syntax.

Well, the above is (supposed to be) used for documenting the signature 
of C-functions.  Read "Documentation strings" in 


Anyway, I just happen to think that adding decorator syntax is not the only
viable solution to all problems reported so far. 

> >>If decorators do not make
> >>Python 2.4, that is another major release cycle that extensions such  
> >>as
> >>PyObjC and ctypes will be hampered by lack of syntax... to the point
> >>where I'd be inclined to just fork Python (or Stackless, more likely)
> >>in order to get the syntax.
> >
> >Nah, just work with us on PyPy to allow it to add decorator syntax
> >at runtime :-)
> That'd be an option, if I could wait a few years until it's capable  
> enough to do everything it needs to do.

I am not sure it will take that long but i see your point :-)



More information about the Python-Dev mailing list