[Python-bugs-list] [ python-Bugs-419390 ] base64.py could be smarter...
noreply@sourceforge.net
noreply@sourceforge.net
Wed, 06 Jun 2001 14:41:02 -0700
Bugs item #419390, was updated on 2001-04-26 23:57
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=419390&group_id=5470
Category: Python Library
Group: Feature Request
Status: Open
Resolution: None
Priority: 5
Submitted By: Anthony Baxter (anthonybaxter)
Assigned to: Peter Schneider-Kamp (nowonder)
Summary: base64.py could be smarter...
Initial Comment:
base64.encodestring and decodestring take the
provided string, wrap it in a StringIO, then
pass it to encode/decode which uses read() to
pull it back out again.
Seems pretty inefficient.
Replacing decodestring with:
return binascii.a2b_base64(s)
results in a speedup of a factor of 16 or so.
(my sample: a 2Mb encoded voice message - takes
an average of 10s in the current form, and 0.6s
using just binascii.)
A similar speedup for encodestring seems possible.
----------------------------------------------------------------------
>Comment By: Tim Peters (tim_one)
Date: 2001-06-06 14:41
Message:
Logged In: YES
user_id=31435
Give this a whirl (remove leading periods, inserted to
default SF space-mangling):
.def encodestring(s):
. pieces = []
. for i in range(0, len(s), MAXBINSIZE):
. chunk = s[i : i + MAXBINSIZE]
. pieces.append(binascii.b2a_base64(chunk))
. return "".join(pieces)
----------------------------------------------------------------------
Comment By: Peter Schneider-Kamp (nowonder)
Date: 2001-06-06 14:17
Message:
Logged In: YES
user_id=14463
Looks good to me. Uploaded (extremely small) patch #430846.
Unfortunately speeding up encoding of a String seems to be
harder (binascii.b2a_base64 accepts at most 76 bytes). Ideas
anyone?
----------------------------------------------------------------------
Comment By: Jeremy Hylton (jhylton)
Date: 2001-05-07 21:27
Message:
Logged In: YES
user_id=31392
Anthony,
Could you submit a patch?
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=419390&group_id=5470