Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faster urllib.urlparse utility functions #67751

Closed
serhiy-storchaka opened this issue Mar 2, 2015 · 2 comments
Closed

Faster urllib.urlparse utility functions #67751

serhiy-storchaka opened this issue Mar 2, 2015 · 2 comments
Assignees
Labels
performance Performance or resource usage stdlib Python modules in the Lib dir

Comments

@serhiy-storchaka
Copy link
Member

BPO 23563
Nosy @serhiy-storchaka
Files
  • urlparse_split_faster.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2015-03-03.18:29:17.223>
    created_at = <Date 2015-03-02.15:05:03.305>
    labels = ['library', 'performance']
    title = 'Faster urllib.urlparse utility functions'
    updated_at = <Date 2015-03-03.18:29:17.222>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2015-03-03.18:29:17.222>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2015-03-03.18:29:17.223>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2015-03-02.15:05:03.305>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['38300']
    hgrepos = []
    issue_num = 23563
    keywords = ['patch']
    message_count = 2.0
    messages = ['237048', '237156']
    nosy_count = 2.0
    nosy_names = ['python-dev', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'performance'
    url = 'https://bugs.python.org/issue23563'
    versions = ['Python 3.5']

    @serhiy-storchaka
    Copy link
    Member Author

    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:password@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.

    @serhiy-storchaka serhiy-storchaka self-assigned this Mar 2, 2015
    @serhiy-storchaka serhiy-storchaka added stdlib Python modules in the Lib dir performance Performance or resource usage labels Mar 2, 2015
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 3, 2015

    New changeset 461afc24fabc by Serhiy Storchaka in branch 'default':
    Issue bpo-23563: Optimized utility functions in urllib.parse.
    https://hg.python.org/cpython/rev/461afc24fabc

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    performance Performance or resource usage stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant