Skip to content

Correct reuse argument tuple in property descriptor #68464

Description

@serhiy-storchaka
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']

    Activity

    1. serhiy-storchaka commented on May 24, 2015

      @serhiy-storchaka
      MemberAuthor

      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.

    2. added
      interpreter-core(Objects, Python, Grammar, and Parser dirs)
      type-crashA hard crash of the interpreter, possibly with a core dump
      on May 24, 2015
    3. serhiy-storchaka commented on May 24, 2015

      @serhiy-storchaka
      MemberAuthor

      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

    4. rhettinger commented on May 24, 2015

      @rhettinger
      Contributor

      LGTM, go ahead and apply.

    5. serhiy-storchaka commented on May 24, 2015

      @serhiy-storchaka
      MemberAuthor

      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.

    6. python-dev commented on May 24, 2015

      python-devmannequin
      Mannequin

      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

    7. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-crashA hard crash of the interpreter, possibly with a core dump

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions