New submission from Serhiy Storchaka: Proposed patch optimizes utility functions in the urllib.parse module.
$ ./python -m timeit -s "from urllib.parse import splittype" -- "splittype('type:'+'x'*1000)" Unpatched: 100000 loops, best of 3: 17 usec per loop Patched: 100000 loops, best of 3: 15 usec per loop $ ./python -m timeit -s "from urllib.parse import splithost" -- "splithost('//www.example.org:80/foo/bar/baz.html')" Unpatched: 100000 loops, best of 3: 12.7 usec per loop Patched: 100000 loops, best of 3: 10.6 usec per loop $ ./python -m timeit -s "from urllib.parse import splithost" -- "splithost('//www.example.org:80')" Unpatched: 100000 loops, best of 3: 9.34 usec per loop Patched: 100000 loops, best of 3: 9.09 usec per loop $ ./python -m timeit -s "from urllib.parse import splituser" -- "splituser('username:passw...@example.org:80')" Unpatched: 100000 loops, best of 3: 8.76 usec per loop Patched: 100000 loops, best of 3: 3.1 usec per loop $ ./python -m timeit -s "from urllib.parse import splituser" -- "splituser('example.org:80')" Unpatched: 100000 loops, best of 3: 5.89 usec per loop Patched: 100000 loops, best of 3: 1.98 usec per loop $ ./python -m timeit -s "from urllib.parse import splitpasswd" -- "splitpasswd('username:password')" Unpatched: 100000 loops, best of 3: 7.38 usec per loop Patched: 100000 loops, best of 3: 3.08 usec per loop $ ./python -m timeit -s "from urllib.parse import splitpasswd" -- "splitpasswd('username')" Unpatched: 100000 loops, best of 3: 5.35 usec per loop Patched: 100000 loops, best of 3: 1.92 usec per loop $ ./python -m timeit -s "from urllib.parse import splitnport" -- "splitnport('example.org:80')" Unpatched: 100000 loops, best of 3: 13.2 usec per loop Patched: 100000 loops, best of 3: 6.58 usec per loop $ ./python -m timeit -s "from urllib.parse import splitnport" -- "splitnport('example.org')" Unpatched: 100000 loops, best of 3: 6.03 usec per loop Patched: 100000 loops, best of 3: 2.37 usec per loop $ ./python -m timeit -s "from urllib.parse import splitquery" -- "splitquery('/path?query')" Unpatched: 100000 loops, best of 3: 8.03 usec per loop Patched: 100000 loops, best of 3: 3.01 usec per loop $ ./python -m timeit -s "from urllib.parse import splitquery" -- "splitquery('/path')" Unpatched: 100000 loops, best of 3: 5.21 usec per loop Patched: 1000000 loops, best of 3: 1.91 usec per loop $ ./python -m timeit -s "from urllib.parse import splitvalue" -- "splitvalue('attr=value')" Unpatched: 100000 loops, best of 3: 7.37 usec per loop Patched: 100000 loops, best of 3: 2.97 usec per loop $ ./python -m timeit -s "from urllib.parse import splitvalue" -- "splitvalue('attr')" Unpatched: 100000 loops, best of 3: 5.13 usec per loop Patched: 1000000 loops, best of 3: 1.9 usec per loop This functions are not documented but used in the stdlib and third-party code. ---------- assignee: serhiy.storchaka components: Library (Lib) files: urlparse_split_faster.patch keywords: patch messages: 237048 nosy: serhiy.storchaka priority: normal severity: normal stage: patch review status: open title: Faster urllib.urlparse utility functions type: performance versions: Python 3.5 Added file: http://bugs.python.org/file38300/urlparse_split_faster.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue23563> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com