◐ Shell
reader mode source ↗
Skip to content

bpo-30156: Remove property_descr_get() optimization#9541

Merged
vstinner merged 1 commit into
python:masterfrom
vstinner:property_descr_get
Oct 1, 2018
Merged

bpo-30156: Remove property_descr_get() optimization#9541
vstinner merged 1 commit into
python:masterfrom
vstinner:property_descr_get

Conversation

@vstinner

@vstinner vstinner commented Sep 24, 2018

Copy link
Copy Markdown
Member

property_descr_get() uses a "cached" tuple to optimize function
calls. But this tuple can be discovered in debug mode with
sys.getobjects(). Remove the optimization, it's not really worth it
and it causes 3 different crashes.

Microbenchmark:

./python -m perf timeit -v
-s "from collections import namedtuple; P = namedtuple('P', 'x y'); p = P(1, 2)"
--duplicate 1024 "p.x"

Result:

Mean +- std dev: [ref] 32.8 ns +- 0.8 ns -> [patch] 40.4 ns +- 1.3 ns: 1.23x slower (+23%)

https://bugs.python.org/issue30156

property_descr_get() uses a "cached" tuple to optimize function
calls. But this tuple can be discovered in debug mode with
sys.getobjects(). Remove the optimization, it's not really worth it
and it causes 3 different crashes last years.

Microbenchmark:

./python -m perf timeit -v \
    -s "from collections import namedtuple; P = namedtuple('P', 'x y'); p = P(1, 2)" \
    --duplicate 1024 "p.x"

Result:

Mean +- std dev: [ref] 32.8 ns +- 0.8 ns -> [patch] 40.4 ns +- 1.3 ns: 1.23x slower (+23%)
@vstinner

Copy link
Copy Markdown
Member Author

I rewrote my commit to add a NEWS entry and update the commit message.

@vstinner vstinner merged commit e972c13 into python:master Oct 1, 2018
@vstinner vstinner deleted the property_descr_get branch October 1, 2018 10:03
@vstinner

vstinner commented Oct 1, 2018

Copy link
Copy Markdown
Member Author

Thanks for the review @rhettinger ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants