Skip to content

PyCode_GetCode could be faster #93382

@Fidget-Spinner

Description

@Fidget-Spinner

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy