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

Correct reuse argument tuple in property descriptor #68464

Closed
serhiy-storchaka opened this issue May 24, 2015 · 5 comments
Closed

Correct reuse argument tuple in property descriptor #68464

serhiy-storchaka opened this issue May 24, 2015 · 5 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@serhiy-storchaka
Copy link
Member

BPO 24276
Nosy @warsaw, @rhettinger, @ericvsmith, @ericsnowcurrently, @serhiy-storchaka, @llllllllll
Files
  • property_cached_args.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-05-24.20:32:03.648>
    created_at = <Date 2015-05-24.13:11:49.739>
    labels = ['interpreter-core', 'type-crash']
    title = 'Correct reuse argument tuple in property descriptor'
    updated_at = <Date 2015-05-24.20:32:03.648>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2015-05-24.20:32:03.648>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2015-05-24.20:32:03.648>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2015-05-24.13:11:49.739>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['39482']
    hgrepos = []
    issue_num = 24276
    keywords = ['patch']
    message_count = 5.0
    messages = ['243980', '243983', '243992', '243993', '243998']
    nosy_count = 7.0
    nosy_names = ['barry', 'rhettinger', 'eric.smith', 'python-dev', 'eric.snow', 'serhiy.storchaka', 'llllllllll']
    pr_nums = []
    priority = 'high'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue24276'
    versions = ['Python 3.5']

    @serhiy-storchaka
    Copy link
    Member Author

    Property descriptor getter uses cached tuple for args (bpo-23910). This can cause problems when called function use args after reading other property or save args. For now I know only one example - clru_cache_3.patch in bpo-14373.

    Proposed patch use cached tuple in more robust manner.

    @serhiy-storchaka serhiy-storchaka added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump labels May 24, 2015
    @serhiy-storchaka
    Copy link
    Member Author

    Affect on performance:

    $ ./python -m timeit -r 11 -s "from collections import namedtuple as n;a = n('n', 'a b c')(1, 2, 3)"

    Unpatched: 10000000 loops, best of 11: 0.0567 usec per loop
    Patched : 10000000 loops, best of 11: 0.0567 usec per loop

    @rhettinger
    Copy link
    Contributor

    LGTM, go ahead and apply.

    @serhiy-storchaka
    Copy link
    Member Author

    Sorry, it was incorrect microbenchmark. Correct is:

    $ ./python -m timeit -r 11 -s "from collections import namedtuple as n;a = n('n', 'a b c')(1, 2, 3)" -- "a.a"
    3.4          : 1000000 loops, best of 11: 0.601 usec per loop
    3.5 unpatched: 1000000 loops, best of 11: 0.445 usec per loop
    3.5 patched  : 1000000 loops, best of 11: 0.454 usec per loop

    There is small slowdown (2%), but it is only small part of the gain of the optimization.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 24, 2015

    New changeset 5dbf3d932a59 by Serhiy Storchaka in branch 'default':
    Issue bpo-24276: Fixed optimization of property descriptor getter.
    https://hg.python.org/cpython/rev/5dbf3d932a59

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants