You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Correct reuse argument tuple in property descriptor #68464
Property descriptor getter uses cached tuple for args (bpo-23910). This can cause problems when called function use args after reading other property or save args. For now I know only one example - clru_cache_3.patch in bpo-14373.
Proposed patch use cached tuple in more robust manner.
Sorry, it was incorrect microbenchmark. Correct is:
$ ./python -m timeit -r 11 -s "from collections import namedtuple as n;a = n('n', 'a b c')(1, 2, 3)" -- "a.a"
3.4 : 1000000 loops, best of 11: 0.601 usec per loop
3.5 unpatched: 1000000 loops, best of 11: 0.445 usec per loop
3.5 patched : 1000000 loops, best of 11: 0.454 usec per loop
There is small slowdown (2%), but it is only small part of the gain of the optimization.
Activity
serhiy-storchaka commentedon May 24, 2015
Property descriptor getter uses cached tuple for args (bpo-23910). This can cause problems when called function use args after reading other property or save args. For now I know only one example - clru_cache_3.patch in bpo-14373.
Proposed patch use cached tuple in more robust manner.
serhiy-storchaka commentedon May 24, 2015
Affect on performance:
$ ./python -m timeit -r 11 -s "from collections import namedtuple as n;a = n('n', 'a b c')(1, 2, 3)"Unpatched: 10000000 loops, best of 11: 0.0567 usec per loop
Patched : 10000000 loops, best of 11: 0.0567 usec per loop
rhettinger commentedon May 24, 2015
LGTM, go ahead and apply.
serhiy-storchaka commentedon May 24, 2015
Sorry, it was incorrect microbenchmark. Correct is:
There is small slowdown (2%), but it is only small part of the gain of the optimization.
python-dev commentedon May 24, 2015
New changeset 5dbf3d932a59 by Serhiy Storchaka in branch 'default':
Issue bpo-24276: Fixed optimization of property descriptor getter.
https://hg.python.org/cpython/rev/5dbf3d932a59