mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
Optimize bytes.fromhex() and bytearray.fromhex()
Issue #25401: Optimize bytes.fromhex() and bytearray.fromhex(): they are now between 2x and 3.5x faster. Changes: * Use a fast-path working on a char* string for ASCII string * Use a slow-path for non-ASCII string * Replace slow hex_digit_to_int() function with a O(1) lookup in _PyLong_DigitValue precomputed table * Use _PyBytesWriter API to handle the buffer * Add unit tests to check the error position in error messages
This commit is contained in:
parent
ebcf9edc05
commit
2bf8993db9
7 changed files with 101 additions and 95 deletions
|
|
@ -161,6 +161,9 @@ Optimizations
|
|||
* ``bytearray % args`` is now between 2.5 and 5 times faster. (Contributed by
|
||||
Victor Stinner in :issue:`25399`).
|
||||
|
||||
* Optimize :meth:`bytes.fromhex` and :meth:`bytearray.fromhex`: they are now
|
||||
between 2x and 3.5x faster. (Contributed by Victor Stinner in :issue:`25401`).
|
||||
|
||||
|
||||
Build and C API Changes
|
||||
=======================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue