]> granicus.if.org Git - python/commit
bpo-30156: Remove property_descr_get() optimization (GH-9541)
authorVictor Stinner <vstinner@redhat.com>
Mon, 1 Oct 2018 10:03:22 +0000 (03:03 -0700)
committerGitHub <noreply@github.com>
Mon, 1 Oct 2018 10:03:22 +0000 (03:03 -0700)
commite972c13624c32d0efdceb08ff83917fb6b488525
treeb29476556514fcb9092547df2cdc7d4e29712a20
parent9df100286b35f1f9fa85976d573981f558805b3f
bpo-30156: Remove property_descr_get() optimization (GH-9541)

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%)
Misc/NEWS.d/next/Core and Builtins/2018-09-24-17-51-15.bpo-30156.pH0j5j.rst [new file with mode: 0644]
Objects/descrobject.c