On 06/07/2012 10:08 AM, Eric Snow wrote: >> I'm missing something here. Can you give me an example of modifying an >> existing function object such that its Signature would change? Decorators >> implementing a closure with a different signature don't count--they return a >> new function object. > I doubt there are any but corner cases to demonstrate here. I'd don't > presume to say what use there may be in changing a function's state. > However, the fact is that a change to any of the following would cause > a cached __signature__ to be out of sync: > > * f.__annotations__ > * f.__closure__ > * f.__code__ > [... other dunder attributes elided ...] In other words: this is possible but extremely unlikely, and will only be done knowingly and with deliberate intent by a skilled practitioner. I think it's reasonable to declare that, if you're monkeying around with dunder attributes on a function, it's up to you to clear the f.__signature__ cache if it's set. Like Spiderman's uncle Cliff Robertson said: with great power comes great responsibility. I am now firmly in the "using __signature__ as a cache is fine, don't make copies for no reason" camp. //arry/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20120607/59900aed/attachment.html>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4