This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients pitrou, serhiy.storchaka, vstinner
Date 2014-03-10.09:35:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
According to tracemalloc, "import base64" allocates 920.6 kB of memory. The 3 top locations are:

Lib/ size=420 KiB, count=7226, average=59 B
    _b85chars2 = [(a + b) for a in _b85chars for b in _b85chars]
Lib/ size=420 KiB, count=7226, average=59 B
    _a85chars2 = [(a + b) for a in _a85chars for b in _a85chars]
Lib/ size=59.8 KiB, count=1025, average=60 B
    _b32tab2 = [a + b for a in _b32tab for b in _b32tab]

Compare it to Python 3.3: base64 of Python 3.3 only allocates 10.3 kB. (I installed tracemalloc manually on Python 3.3 to get this number.)

I suggest to initialized these precomputed tables to None, and compute them at the first call to b32encode() / b85encode() / a85encode().

The new Base65 and Ascii85 codecs were added by the issue #17618.

_b32tab2 comes from changeset (1b5ef05d6ced) of issue #17812: "quadratic complexity of base64.b32encode(). Optimize base64.b32encode() and base64.b32decode() (speed up to 3x)." So 3.3 branch is also affected (for the base32 table).
Date User Action Args
2014-03-10 09:35:27vstinnersetrecipients: + vstinner, pitrou, serhiy.storchaka
2014-03-10 09:35:27vstinnersetmessageid: <>
2014-03-10 09:35:27vstinnerlinkissue20879 messages
2014-03-10 09:35:27vstinnercreate