diff options
author | Victor Stinner <vstinner@python.org> | 2020-12-25 23:41:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-25 23:41:46 (GMT) |
commit | ba3d67c2fb04a7842741b1b6da5d67f22c579f33 (patch) | |
tree | d5d8f09c94f413f54ce6014e253ad1de59548bba /Misc | |
parent | f0853bcedf8531856bdda149a540eaa0fc26e692 (diff) | |
download | cpython-ba3d67c2fb04a7842741b1b6da5d67f22c579f33.zip cpython-ba3d67c2fb04a7842741b1b6da5d67f22c579f33.tar.gz cpython-ba3d67c2fb04a7842741b1b6da5d67f22c579f33.tar.bz2 |
bpo-39465: Fix _PyUnicode_FromId() for subinterpreters (GH-20058)
Make _PyUnicode_FromId() function compatible with subinterpreters.
Each interpreter now has an array of identifier objects (interned
strings decoded from UTF-8).
* Add PyInterpreterState.unicode.identifiers: array of identifiers
objects.
* Add _PyRuntimeState.unicode_ids used to allocate unique indexes
to _Py_Identifier.
* Rewrite the _Py_Identifier structure.
Microbenchmark on _PyUnicode_FromId(&PyId_a) with _Py_IDENTIFIER(a):
[ref] 2.42 ns +- 0.00 ns -> [atomic] 3.39 ns +- 0.00 ns: 1.40x slower
This change adds 1 ns per _PyUnicode_FromId() call in average.
Diffstat (limited to 'Misc')
-rw-r--r-- | Misc/NEWS.d/next/Core and Builtins/2020-05-13-18-50-27.bpo-39465.j7nl6A.rst | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-05-13-18-50-27.bpo-39465.j7nl6A.rst b/Misc/NEWS.d/next/Core and Builtins/2020-05-13-18-50-27.bpo-39465.j7nl6A.rst new file mode 100644 index 0000000..c29b5e1 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2020-05-13-18-50-27.bpo-39465.j7nl6A.rst @@ -0,0 +1,3 @@ +Make :c:func:`_PyUnicode_FromId` function compatible with subinterpreters. +Each interpreter now has an array of identifier objects (interned strings +decoded from UTF-8). Patch by Victor Stinner. |