Skip to content

Major slowdown on large listcomp#117108

@tim-one

Description

@tim-one

Bug report

Bug description:

That started within the last 48 hours, on the main branch. Here's test code; it's possible it could be simplified

if1: classObj: def__init__(self, i): self.val=iimportsysprint(sys.version) fromtimeimportperf_counterasnowstart=now() xs= [Obj(i) foriinrange(2**21)] finish=now() print(finish-start)

Under 3.12.2 it takes about a second, but under current main about 21 seconds.

C:\Code\Python\PCbuild>py \MyPy\small.py 3.12.2 (tags/v3.12.2:6abddd9, Feb 6 2024, 21:26:36) [MSC v.1937 64 bit (AMD64)] 0.9562742999987677 C:\Code\Python\PCbuild>amd64\python.exe \MyPy\small.py 3.13.0a5+ (heads/main:f4cc77d494, Mar 20 2024, 20:28:50) [MSC v.1939 64 bit (AMD64)] 20.99507549998816 

If the size of the list is increased, it appears to suffer much worse than linear-time slowdown.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Windows

Linked PRs

Metadata

Metadata

Assignees

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagerelease-blockertype-bugAn unexpected behavior, bug, or error

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions