GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||
GeezerVison is showing github.com — Performance regression: O(N²) compile time for large constant tuples after const folding moved to CFG · Issue #146455 · python/cpython Closed Labels 3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usagetype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DescriptionBug reportBug description:After gh-126835 moved constant folding from AST to CFG (specifically gh-130769 for tuple folding and gh-129550 for unary/binary op folding), compiling files with large constant tuples suffers from an O(N²) slowdown. The root cause is for (index = 0; index < PyList_GET_SIZE(consts); index++) { if (PyList_GET_ITEM(consts, index) == newconst) { break; } } Before gh-126835, large constant tuples were folded in one shot at the AST stage, so This also affects unary/binary op folding (
Performance impact (N=100K):
Reproducer: import sys, time N = int(sys.argv[1]) if len(sys.argv) > 1 else 100000 elements = ", ".join(f"({i * 0.001:.6f}, {i * 0.002:.6f})" for i in range(N)) source = f"vertices = ({elements},)" t0 = time.perf_counter() code_obj = compile(source, "<test>", "exec") t1 = time.perf_counter() print(f"Compile time: {t1-t0:.4f}s", flush=True) CPython versions tested on:3.14, 3.15 Operating systems tested on:Linux Linked PRsActivity
MetadataMetadataAssigneesLabels3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usagetype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error ProjectsMilestoneRelationshipsDevelopmentIssue 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. |