Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34k
Open
Description
Base64 decoding was optimized in#124951. But the optimization only worked to the first ignored character. The proposed PR makes it used even if there are some ignored characters (e.g. multiline data).
Examples:
$ ./python -m timeit -s 'import binascii; a = (b"a"*76+b"\n")*1000' 'binascii.a2b_base64(a)'baseline: 10000 loops, best of 5: 37.7 usec per loopoptimized: 10000 loops, best of 5: 20.2 usec per loop$ ./python -m timeit -s 'import binascii; a = (b"a"*76+b"\n")*1000' 'binascii.a2b_base64(a, ignorechars=b" \t\n\r\v")'baseline: 5000 loops, best of 5: 42.7 usec per loopoptimized: 10000 loops, best of 5: 21.3 usec per loopFor comparison, Base64 decoding without ignored characters:
$ ./python -m timeit -s 'import binascii; a = (b"a"*76)*1000' 'binascii.a2b_base64(a)'20000 loops, best of 5: 17.3 usec per loop