Repository navigation
Conversation
Owner
Author
|
Results of bench_loc.py:
The UTF-8 cache makes os.strerror() 2.0x faster: 233 ns +- 4 ns => 143 ns +- 4 ns. Raw numbers: With the UTF-8 cache, FIXME: _Py_UpdateLocale() is not called at Python startup, locale.setlocale() must be called to test the optimization. |
vstinner
force-pushed
the
WIP_current_locale_utf8
branch
from
November 16, 2026 23:45
b276174 to
bfb9e28
Compare
Owner
Author
|
Results of python#161455 benchmark:
I updated the branch so the cache is used without having to call locale.setlocale(). |
vstinner
force-pushed
the
WIP_current_locale_utf8
branch
from
November 17, 2026 00:09
bfb9e28 to
225058b
Compare
* Add also UTF-8 fast-path to _Py_DecodeLocale() and _Py_EncodeLocale(). * Add _PyRuntime.current_locale_is_utf8 to remember if the LC_CTYPE encoding is UTF-8. * Add _PyRuntime.cached_locale_encoding to make sure that setlocale(LC_CTYPE) or setlocale(LC_ALL) was not called outside Python. * Rename _Py_ERROR_UNKNOWN to _Py_ERROR_UNSET. * Rename _Py_ERROR_OTHER to _Py_ERROR_UNKNOWN. HACKS for the micro-benchmark: * Add bench_loc.py. * Add "y#" fast-path to Argument Clinic. * Move unicode_decodelocale from _testlimitedcapi to _testcapi to use faster Argument Clinic code. * Need to define _Py_IDENTIFIER() API if Py_BUILD_CORE macro is defined, so that _testcapi can test this API. _testcapi has to define Py_BUILD_CORE for Argument Clinic.
vstinner
force-pushed
the
WIP_current_locale_utf8
branch
from
November 17, 2026 13:48
225058b to
791b3fe
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HACK for the micro-benchmark: