mirror of
https://github.com/python/cpython.git
synced 2025-07-07 11:25:30 +00:00
gh-118761: substitute re
import in base64.b16decode
for a more efficient alternative (#128736)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Co-authored-by: Chris Markiewicz <effigies@gmail.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
This commit is contained in:
parent
859db49029
commit
bbd3300ae8
3 changed files with 15 additions and 2 deletions
|
@ -728,6 +728,15 @@ asyncio
|
|||
reduces memory usage.
|
||||
(Contributed by Kumar Aditya in :gh:`107803`.)
|
||||
|
||||
|
||||
base64
|
||||
------
|
||||
|
||||
* Improve the performance of :func:`base64.b16decode` by up to ten times,
|
||||
and reduce the import time of :mod:`base64` by up to six times.
|
||||
(Contributed by Bénédikt Tran, Chris Markiewicz, and Adam Turner in :gh:`118761`.)
|
||||
|
||||
|
||||
io
|
||||
---
|
||||
* :mod:`io` which provides the built-in :func:`open` makes less system calls
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
# Modified 30-Dec-2003 by Barry Warsaw to add full RFC 3548 support
|
||||
# Modified 22-May-2007 by Guido van Rossum to use bytes everywhere
|
||||
|
||||
import re
|
||||
import struct
|
||||
import binascii
|
||||
|
||||
|
@ -284,7 +283,7 @@ def b16decode(s, casefold=False):
|
|||
s = _bytes_from_decode_data(s)
|
||||
if casefold:
|
||||
s = s.upper()
|
||||
if re.search(b'[^0-9A-F]', s):
|
||||
if s.translate(None, delete=b'0123456789ABCDEF'):
|
||||
raise binascii.Error('Non-base16 digit found')
|
||||
return binascii.unhexlify(s)
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
Improve the performance of :func:`base64.b16decode` by up to ten times
|
||||
by more efficiently checking the byte-string for hexadecimal digits.
|
||||
Reduce the import time of :mod:`base64` by up to six times,
|
||||
by no longer importing :mod:`re`.
|
||||
Patch by Bénédikt Tran, Chris Markiewicz, and Adam Turner.
|
Loading…
Add table
Add a link
Reference in a new issue