GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `PyCode_GetCode` could be faster · Issue #93382 · python/cpython

PyCode_GetCode could be faster #93382

New issue
Copy link
New issue
Copy link
Closed
#93383
Closed
PyCode_GetCode could be faster#93382
#93383
Copy link
Labels
3.12only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usage

Description

@Fidget-Spinner
Fidget-Spinner
opened on May 31, 2022
Issue body actions

This potentially affects tools like coverage.py. It also means anything using co_code in CPython frequently is significantly slower. Note that pre-3.11, most code would assume this operation is O(1), so it's probably called more often than we expect.

We should lazily initialise a hidden _co_code field and cache it there. Currently it creates a fresh bytes object on each co_code access. This is at best O(n).

Reacted by Donghee Na

Activity

  1. Fidget-Spinner
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on May 31, 2022
  2. kumaraditya303
    added
    performancePerformance or resource usagePerformance or resource usage
    and removed
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on May 31, 2022
  3. Fidget-Spinner
    changed the title [-]`PyCode_GetCode` is really slow[/-] [+]`PyCode_GetCode` could be faster[/+] on May 31, 2022
  4. AA-Turner
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    3.12only security fixesonly security fixes
    on May 31, 2022
  5. Fidget-Spinner
    closed this as completedin #93383on Jun 3, 2022
  6. Fidget-Spinner
    added 2 commits that reference this issue on Jun 3, 2022

    gh-93382: Cache result of `PyCode_GetCode` in codeobject (GH-93383)

    d52ffc1

    pythongh-93382: Cache result of `PyCode_GetCode` in codeobject (pytho…

    13642ce
  7. pablogsal
    added a commit that references this issue on Jun 23, 2022

    [3.11] gh-93382: Cache result of `PyCode_GetCode` in codeobject (GH-9…

    852b4d4
  8. Fidget-Spinner
    added a commit that references this issue on Jun 24, 2022

    gh-93382: Sync up `co_code` changes with 3.11 (GH-94227)

    50a5ab2
  9. serhiy-storchaka
    added a commit that references this issue on Jun 26, 2022

    Revert 30935 defer bpo45162 to 312 (#94285)

    1ffde3e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usage

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.