[Python-Dev] PEP 362: 4th edition

Larry Hastings larry at hastings.org
Fri Jun 15 23:38:03 CEST 2012


On 06/15/2012 02:13 PM, Antoine Pitrou wrote:
> I'm not sure I understand. The PEP already says signatures are computed
> lazily. Is there an exception for built-in functions?

Right now we have no way to automatically generate signatures for 
built-in functions.  So, as of current trunk, any such signatures would 
have to be built by hand.

If we could somehow produce signature information in C, what then?  Two 
possible approaches suggest themselves:

 1. Pre-generate the signatures and cache them in the __signature__
    attribute.
 2. Add a callback, perhaps named __get_signature__(), which calculates
    the signature and returns it.


Both approaches have downsides.  The former means generation is not lazy 
and therefore consumes more memory.  The latter adds a new attribute to 
builtin functions.

Which is a better approach?  Who knows?  We don't even have the 
signature information in C yet.  As we all learned from Star Trek VI, 
the future is an undiscovered country.  So the PEP deliberately makes no 
ruling here.


//arry/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20120615/ed662ace/attachment.html>


More information about the Python-Dev mailing list