Skip to content

Commit

Permalink
Improve import time of the base64 module.
Browse files Browse the repository at this point in the history
Importing ``base64`` is now six times faster.

The ``re`` module is now locally imported by ``base64.b16decode``
and is no more implicitly exposed as ``base64.re``.
  • Loading branch information
picnixz committed Jan 10, 2025
1 parent aef52ca commit 57c998a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Lib/base64.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -281,6 +280,8 @@ def b16decode(s, casefold=False):
s is incorrectly padded or if there are non-alphabet characters present
in the input.
"""
import re

s = _bytes_from_decode_data(s)
if casefold:
s = s.upper()
Expand Down

0 comments on commit 57c998a

Please sign in to comment.