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 _PyArg_NoKeywords() and like #73646

Closed
serhiy-storchaka opened this issue Feb 6, 2017 · 7 comments
Closed

Speed up _PyArg_NoKeywords() and like #73646

serhiy-storchaka opened this issue Feb 6, 2017 · 7 comments
Labels
3.7 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage

Comments

@serhiy-storchaka
Copy link
Member

BPO 29460
Nosy @rhettinger, @vstinner, @serhiy-storchaka
Files
  • _PyArg_NoKeywords_macro.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 2017-02-06.08:42:42.762>
    created_at = <Date 2017-02-06.08:09:51.078>
    labels = ['interpreter-core', '3.7', 'performance']
    title = 'Speed up _PyArg_NoKeywords() and like'
    updated_at = <Date 2017-02-06.09:47:13.720>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2017-02-06.09:47:13.720>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-02-06.08:42:42.762>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2017-02-06.08:09:51.078>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['46537']
    hgrepos = []
    issue_num = 29460
    keywords = ['patch']
    message_count = 7.0
    messages = ['287098', '287104', '287105', '287106', '287110', '287111', '287114']
    nosy_count = 4.0
    nosy_names = ['rhettinger', 'vstinner', 'python-dev', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'performance'
    url = 'https://bugs.python.org/issue29460'
    versions = ['Python 3.7']

    @serhiy-storchaka
    Copy link
    Member Author

    Proposed patch makes _PyArg_NoKeywords(), _PyArg_NoStackKeywords() and _PyArg_NoPositional() macros. This eliminates the overhead of the cross-module function call in common case.

    This idea was previously discussed in bpo-26822 and raised again in bpo-29452.

    @serhiy-storchaka serhiy-storchaka added 3.7 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage labels Feb 6, 2017
    @rhettinger
    Copy link
    Contributor

    +1

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Feb 6, 2017

    New changeset 82d1c8d15e18 by Serhiy Storchaka in branch 'default':
    Issue bpo-29460: _PyArg_NoKeywords(), _PyArg_NoStackKeywords() and
    https://hg.python.org/cpython/rev/82d1c8d15e18

    @vstinner
    Copy link
    Member

    vstinner commented Feb 6, 2017

    Oh right, I recall that I proposed it. Thanks for this change :-)

    The next question might it: would it be worth it to try using unlikely() macro on (kwargs == NULL) test in the macro? ;-)

    I'm talking about GCC/Clang __builtin_expect:

    #define unlikely(x)     __builtin_expect((x),0)

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Feb 6, 2017

    New changeset f5ef851ff6b26529382747cfea4674158c7c1ebc by Serhiy Storchaka in branch 'master':
    Issue bpo-29460: _PyArg_NoKeywords(), _PyArg_NoStackKeywords() and
    f5ef851

    @serhiy-storchaka
    Copy link
    Member Author

    The next question might it: would it be worth it to try using unlikely()
    macro on (kwargs == NULL) test in the macro? ;-)

    Perhaps this may help in some critical tight loops (in implementations of
    dict, string operations or long integer arithmetic), but I doubt it can have
    any measurable effect when used once per a call of a function calling
    PyArg_Parse* and using many other stuff.

    @vstinner
    Copy link
    Member

    vstinner commented Feb 6, 2017

    I created the issue bpo-29461: "Experiment usage of likely/unlikely in CPython core".

    @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
    3.7 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants