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

Avoid repeated hash calculation in C implementation of OrderedDict #69648

Closed
serhiy-storchaka opened this issue Oct 22, 2015 · 6 comments
Closed
Labels
topic-regex type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

BPO 25462
Nosy @rhettinger, @ezio-melotti, @ericsnowcurrently, @serhiy-storchaka
Files
  • odict_knownhash.patch
  • odict_knownhash_2.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 2015-11-13.13:21:03.744>
    created_at = <Date 2015-10-22.18:15:07.317>
    labels = ['expert-regex', 'type-feature']
    title = 'Avoid repeated hash calculation in C implementation of OrderedDict'
    updated_at = <Date 2015-11-13.13:21:16.246>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2015-11-13.13:21:16.246>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-11-13.13:21:03.744>
    closer = 'serhiy.storchaka'
    components = ['Regular Expressions']
    creation = <Date 2015-10-22.18:15:07.317>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['40838', '40960']
    hgrepos = []
    issue_num = 25462
    keywords = ['patch']
    message_count = 6.0
    messages = ['253343', '254182', '254294', '254296', '254603', '254604']
    nosy_count = 6.0
    nosy_names = ['rhettinger', 'ezio.melotti', 'mrabarnett', 'python-dev', 'eric.snow', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue25462'
    versions = ['Python 3.5', 'Python 3.6']

    @serhiy-storchaka
    Copy link
    Member Author

    There are private _PyDict_*_KnownHash functions that allow to avoid repeated hash calculation in complex operations with a dict. Proposed patch makes C implementation of OrderedDict to use these functions. It is not just an optimization, it makes some OrderedDict methods atomic (or almost atomic), that decreases a chance to desynchronize the linked list with the dict. That is why I suggest to commit the patch in 3.5.

    @serhiy-storchaka serhiy-storchaka added topic-regex type-feature A feature request or enhancement labels Oct 22, 2015
    @serhiy-storchaka
    Copy link
    Member Author

    Could you please make a review of this patch Eric? It is moved to separate issue because it is enough large and complex.

    @rhettinger
    Copy link
    Contributor

    The patch looks correct, and it improves the integrity of the C implementation.

    @ericsnowcurrently
    Copy link
    Member

    I agree with Raymond.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Nov 13, 2015

    New changeset 52ff0c00a404 by Serhiy Storchaka in branch '3.5':
    Issue bpo-25462: The hash of the key now is calculated only once in most
    https://hg.python.org/cpython/rev/52ff0c00a404

    New changeset 828c9b920532 by Serhiy Storchaka in branch 'default':
    Issue bpo-25462: The hash of the key now is calculated only once in most
    https://hg.python.org/cpython/rev/828c9b920532

    @serhiy-storchaka
    Copy link
    Member Author

    Thank you Raymond and Eric.

    @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
    topic-regex type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants