diff options
author | Victor Stinner <vstinner@redhat.com> | 2018-10-01 10:03:22 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-01 10:03:22 (GMT) |
commit | e972c13624c32d0efdceb08ff83917fb6b488525 (patch) | |
tree | b29476556514fcb9092547df2cdc7d4e29712a20 /Misc | |
parent | 9df100286b35f1f9fa85976d573981f558805b3f (diff) | |
download | cpython-e972c13624c32d0efdceb08ff83917fb6b488525.zip cpython-e972c13624c32d0efdceb08ff83917fb6b488525.tar.gz cpython-e972c13624c32d0efdceb08ff83917fb6b488525.tar.bz2 |
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%)
Diffstat (limited to 'Misc')
-rw-r--r-- | Misc/NEWS.d/next/Core and Builtins/2018-09-24-17-51-15.bpo-30156.pH0j5j.rst | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Core and Builtins/2018-09-24-17-51-15.bpo-30156.pH0j5j.rst b/Misc/NEWS.d/next/Core and Builtins/2018-09-24-17-51-15.bpo-30156.pH0j5j.rst new file mode 100644 index 0000000..7086ff4 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2018-09-24-17-51-15.bpo-30156.pH0j5j.rst @@ -0,0 +1,4 @@ +The C function ``property_descr_get()`` uses a "cached" tuple to optimize +function calls. But this tuple can be discovered in debug mode with +:func:`sys.getobjects()`. Remove the optimization, it's not really worth it +and it causes 3 different crashes last years. |