[issue17812] Quadratic complexity in b32encode

2013-05-19 Thread Roundup Robot
Roundup Robot added the comment: New changeset 4b5467d997f1 by Serhiy Storchaka in branch '3.3': Issue #17812: Fixed quadratic complexity of base64.b32encode(). http://hg.python.org/cpython/rev/4b5467d997f1 New changeset 1b5ef05d6ced by Serhiy Storchaka in branch 'default': Issue #17812: Fixed

[issue17812] Quadratic complexity in b32encode

2013-05-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: That is why I proposed two patches. -- versions: +Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17812 ___

[issue17812] Quadratic complexity in b32encode

2013-05-19 Thread Serhiy Storchaka
Changes by Serhiy Storchaka storch...@gmail.com: -- assignee: - serhiy.storchaka resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17812

[issue17812] Quadratic complexity in b32encode

2013-05-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Note that without patches both tests run many minutes. base32_fix.patch causes little (5%) performance degradation for small data ( KB), this is perhaps the cause for the use of string concatenation. However base32_optimize.patch speeds up about 3x for such

[issue17812] Quadratic complexity in b32encode

2013-05-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Note that without patches both tests run many minutes. base32_fix.patch causes little (5%) performance degradation for small data ( KB), this is perhaps the cause for the use of string concatenation. However base32_optimize.patch speeds up about 3x for such

[issue17812] Quadratic complexity in b32encode

2013-05-18 Thread Antoine Pitrou
Antoine Pitrou added the comment: Using a bytearray, rather than accumulating into a list, may reduce memory consumption. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17812 ___

[issue17812] Quadratic complexity in b32encode

2013-05-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Thank you Antoine. Here are updated patches. -- Added file: http://bugs.python.org/file30308/base32_fix_2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17812

[issue17812] Quadratic complexity in b32encode

2013-05-18 Thread Serhiy Storchaka
Changes by Serhiy Storchaka storch...@gmail.com: Added file: http://bugs.python.org/file30309/base32_optimize_2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17812 ___

[issue17812] Quadratic complexity in b32encode

2013-05-18 Thread Serhiy Storchaka
Changes by Serhiy Storchaka storch...@gmail.com: Removed file: http://bugs.python.org/file29971/base32_fix.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17812 ___

[issue17812] Quadratic complexity in b32encode

2013-05-18 Thread Serhiy Storchaka
Changes by Serhiy Storchaka storch...@gmail.com: Removed file: http://bugs.python.org/file29972/base32_optimize.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17812 ___

[issue17812] Quadratic complexity in b32encode

2013-05-18 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- versions: -Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17812 ___ ___ Python-bugs-list

[issue17812] Quadratic complexity in b32encode

2013-05-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I think 3.3 needs a fix. The quadratic complexity is a bug. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17812 ___

[issue17812] Quadratic complexity in b32encode

2013-05-18 Thread Antoine Pitrou
Antoine Pitrou added the comment: Then I would recommend committing the simple patch in 3.3 and the more optimized one in 3.4. Both look fine to me, althgugh I haven't really examined the padding stuff. -- ___ Python tracker rep...@bugs.python.org

[issue17812] Quadratic complexity in b32encode

2013-04-21 Thread Serhiy Storchaka
New submission from Serhiy Storchaka: b32encode accumulates encoded data in a bytes object and this operation has quadratic complexity. Here is a patch, which fixes this issue by accumulating in a list. -- components: Library (Lib) files: base32_fix.patch keywords: patch messages:

[issue17812] Quadratic complexity in b32encode

2013-04-21 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: And here are other patch, which not only fixes an issue with quadratic complexity, but optimize b32encode and b32decode about 2.5 times. Microbenchmarks: ./python -m timeit -r 1 -n 10 -s from base64 import b32encode as encode; data = open('python',

[issue17812] Quadratic complexity in b32encode

2013-04-21 Thread Serhiy Storchaka
Changes by Serhiy Storchaka storch...@gmail.com: Added file: http://bugs.python.org/file29972/base32_optimize.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17812 ___