New submission from Guido van Rossum <gu...@python.org>:

This bug is still present in Python 3.3.  Some people use urlsafe strings *a 
lot*. And they find that the (obvious) implementation in base64.py is way too 
slow.  In fact, I found myself writing the following a few times in App Engine 
libraries:

    # This is 3-4x faster than urlsafe_b64decode()                   
    urlsafe = base64.b64encode(<arg>)
    return urlsafe.rstrip('=').replace('+', '-').replace('/', '_')

Someone from YouTube told me they patch the stdlib for the same reason (they 
claim their solution is 10x faster).

IIUC the cause of the slowness is the (mostly irrelevant) generality in 
b64encode and the _translate() function.

----------
components: Library (Lib)
keywords: easy
messages: 163420
nosy: gvanrossum
priority: normal
severity: normal
stage: needs patch
status: open
title: base64.urlsafe_b64**code are too slow
type: performance
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue15138>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to