This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Correct reuse argument tuple in property descriptor
Type: crash Stage: resolved
Components: Interpreter Core Versions: Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: barry, eric.smith, eric.snow, llllllllll, python-dev, rhettinger, serhiy.storchaka
Priority: high Keywords: patch

Created on 2015-05-24 13:11 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
property_cached_args.patch serhiy.storchaka, 2015-05-24 13:11 review
Messages (5)
msg243980 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-05-24 13:11
Property descriptor getter uses cached tuple for args (issue23910). 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 issue14373.

Proposed patch use cached tuple in more robust manner.
msg243983 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-05-24 13:30
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
msg243992 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2015-05-24 16:53
LGTM, go ahead and apply.
msg243993 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-05-24 17:15
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.
msg243998 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-05-24 18:38
New changeset 5dbf3d932a59 by Serhiy Storchaka in branch 'default':
Issue #24276: Fixed optimization of property descriptor getter.
https://hg.python.org/cpython/rev/5dbf3d932a59
History
Date User Action Args
2022-04-11 14:58:17adminsetgithub: 68464
2015-05-24 20:32:03serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2015-05-24 18:38:44python-devsetmessages: + msg243998
2015-05-24 17:15:39serhiy.storchakasetmessages: + msg243993
2015-05-24 16:53:30rhettingersetassignee: serhiy.storchaka
messages: + msg243992
2015-05-24 13:30:32serhiy.storchakasetmessages: + msg243983
2015-05-24 13:26:30serhiy.storchakalinkissue14373 dependencies
2015-05-24 13:11:49serhiy.storchakacreate