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

speed up some ipaddress properties #65712

Closed
pitrou opened this issue May 15, 2014 · 5 comments
Closed

speed up some ipaddress properties #65712

pitrou opened this issue May 15, 2014 · 5 comments
Labels
performance Performance or resource usage stdlib Python modules in the Lib dir

Comments

@pitrou
Copy link
Member

pitrou commented May 15, 2014

BPO 21513
Nosy @ncoghlan, @pitrou, @serhiy-storchaka, @MojoVampire
Files
  • ipaddr_props.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 = None
    closed_at = <Date 2014-05-23.21:12:52.731>
    created_at = <Date 2014-05-15.21:24:37.802>
    labels = ['library', 'performance']
    title = 'speed up some ipaddress properties'
    updated_at = <Date 2014-05-23.21:12:52.729>
    user = 'https://github.com/pitrou'

    bugs.python.org fields:

    activity = <Date 2014-05-23.21:12:52.729>
    actor = 'pitrou'
    assignee = 'none'
    closed = True
    closed_date = <Date 2014-05-23.21:12:52.731>
    closer = 'pitrou'
    components = ['Library (Lib)']
    creation = <Date 2014-05-15.21:24:37.802>
    creator = 'pitrou'
    dependencies = []
    files = ['35260']
    hgrepos = []
    issue_num = 21513
    keywords = ['patch']
    message_count = 5.0
    messages = ['218630', '218974', '218999', '219000', '219002']
    nosy_count = 6.0
    nosy_names = ['ncoghlan', 'pitrou', 'pmoody', 'python-dev', 'serhiy.storchaka', 'josh.r']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'performance'
    url = 'https://bugs.python.org/issue21513'
    versions = ['Python 3.5']

    @pitrou
    Copy link
    Member Author

    pitrou commented May 15, 2014

    Some properties on IPv4Address and IPv6Address instantiate one or several network objects each time they are computed. Instead these characteristic networks can be computed once and for all at module import. Patch attached.

    (note: the lru_cache() decorator seems to mitigate this in micro-benchmarks, but the common pattern is not to call .is_private on always the same address :-))

    @pitrou pitrou added stdlib Python modules in the Lib dir performance Performance or resource usage labels May 15, 2014
    @serhiy-storchaka
    Copy link
    Member

    May be move implementations to parent class? In any case the patch LGTM.

    @pitrou
    Copy link
    Member Author

    pitrou commented May 23, 2014

    May be move implementations to parent class?

    Docstrings are different, though.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 23, 2014

    New changeset 7a28ab8f012f by Antoine Pitrou in branch 'default':
    Issue bpo-21513: Speedup some properties of IP addresses (IPv4Address, IPv6Address) such as .is_private or .is_multicast.
    http://hg.python.org/cpython/rev/7a28ab8f012f

    @pitrou
    Copy link
    Member Author

    pitrou commented May 23, 2014

    Committed, thanks.

    @pitrou pitrou closed this as completed May 23, 2014
    @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

    2 participants