On Sat, Sep 2, 2017 at 6:35 AM, Joe Jevnik via Python-Dev <python-dev at python.org> wrote: > Is it true that checking for refcount == 1 is enough? What if a user wrote: > > args = (compute_integer(), 5) > # give away args to someone > int.__iadd__(*args) > > here `args[0]` still has refcount=1 because only `args` owns this integer. This particular example is safe, because the arguments get passed individually - so 'args' has one reference, plus there's one more for the actual function call (what would be 'self' if it were implemented in Python). There may be other examples that are more dangerous, but my suspicion is that the nature of += with anything other than a simple name will defeat the optimization, since the owning collection will retain a reference until __iadd__ returns. ChrisA
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