[proxy] github.com← back | site home | direct (HTTPS) ↗ | proxy home | ◑ dark◐ light

bpo-39465: Fix _PyUnicode_FromId() for subinterpreters by vstinner · Pull Request #20058 · python/cpython

vstinner

Closed

vstinner changed the title bpo-39465: Fix _PyUnicode_FromId() for subinterpreters [WIP] bpo-39465: Fix _PyUnicode_FromId() for subinterpreters

May 13, 2020

vstinner changed the title [WIP] bpo-39465: Fix _PyUnicode_FromId() for subinterpreters bpo-39465: Fix _PyUnicode_FromId() for subinterpreters

May 19, 2020

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 _Py_Identifier structure.

Benchmark _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.

Merged

Open

adorilson pushed a commit to adorilson/cpython that referenced this pull request

Mar 13, 2021

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.