-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
Use locale.nl_langinfo in _strptime.py
#53161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It might perform better to use locale.nl_langinfo to get the current locale's datetime information instead of reverse-engineering from strftime (need to benchmark to see if this is true). This would need to be conditional as the datetime info might not be exposed through nl_langinfo. |
I would also like to consider using OS strptime on platforms with a decent implementation. |
Not fully possible, We can partially use it, ~33% faster. def _getlang():
lang = locale.setlocale(locale.LC_TIME, None)
encoding = locale.nl_langinfo(locale.CODESET)
return lang, encoding $ python3.14 -m timeit -s "from _strptime import _getlang" "_getlang()"
1000000 loops, best of 5: 298 nsec per loop
$ ./python -m timeit -s "from _strptime import _getlang" "_getlang()"
1000000 loops, best of 5: 203 nsec per loop # ~33% faster Caching the information will result in a decent performance gain. |
This should be a separate issue. |
@picnixz _strptime is currently pure python. This does not need the extension-modules label. It does however need the performance label :-) |
_strptime.py
I never know which part of the date/time API is duplicated in C and which one is not so thanks. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: