]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
Optimize bytes.fromhex() and bytearray.fromhex()
authorVictor Stinner <victor.stinner@gmail.com>
Wed, 14 Oct 2015 09:25:33 +0000 (11:25 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Wed, 14 Oct 2015 09:25:33 +0000 (11:25 +0200)
commit2bf8993db966256d564d87865ceddf0e33c02500
tree8b172dcec9ee6d9584c75ecc933b418b5210963b
parentebcf9edc05c03af38c01d8aeb05494b68169756c
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
Doc/whatsnew/3.6.rst
Include/bytesobject.h
Include/longobject.h
Lib/test/test_bytes.py
Misc/NEWS
Objects/bytearrayobject.c
Objects/bytesobject.c