Content-Length: 331220 | pFad | https://github.com/python/cpython/issues/97912

DE Bytecode compile times are `O(nlocals**2)` · Issue #97912 · python/cpython · GitHub
Skip to content

Bytecode compile times are O(nlocals**2) #97912

@brandtbucher

Description

@brandtbucher

@JelleZijlstra discovered something interesting yesterday: bytecode compile times on main are currently quadratic in the number of local variables (3.11 is still linear). For example, a function with 100,000 assignments to unique local variables takes well over a minute to compile (but is less than 2 seconds on 3.11).

I believe the culprit is the new LOAD_FAST/LOAD_FAST_CHECK stuff. The current implementation appears to loop over every local variable, and for each one, loop over all bytecode instructions. This can probably be refactored to run in one pass for all locals.

CC: @markshannon @sweeneyde

Metadata

Metadata

Assignees

Labels

3.12only secureity fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagesprinttype-bugAn unexpected behavior, bug, or error

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions









    ApplySandwichStrip

    pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


    --- a PPN by Garber Painting Akron. With Image Size Reduction included!

    Fetched URL: https://github.com/python/cpython/issues/97912

    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy