Skip to content

perf: speed up Python stack capture#3147

Merged
Skn0tt merged 1 commit into
microsoft:mainfrom
Skn0tt:skn0tt-benchmark-pr-2836
Jul 23, 2026
Merged

perf: speed up Python stack capture#3147
Skn0tt merged 1 commit into
microsoft:mainfrom
Skn0tt:skn0tt-benchmark-pr-2836

Conversation

@Skn0tt

@Skn0tt Skn0tt commented Jul 22, 2026

Copy link
Copy Markdown
Member

2.0–2.6× faster Playwright calls under pytest; 1.2–1.7× faster standalone.

This replaces inspect.stack(0) with direct f_back traversal. It still captures the full stack, but avoids eagerly constructing FrameInfo objects and inspecting source context on every API call.

Paired page.evaluate("1") benchmarks on Python 3.12:

Sync Async
Standalone 1.16× 1.70×
pytest 2.01× 2.56×

The difference is larger under pytest because its runner stack is deeper.

Re #2836.

Copilot-Session: 44b709b3-a9d6-4b4d-8d82-67fbc663f8e4
@Skn0tt
Skn0tt requested a review from dgozman July 23, 2026 07:48
@Skn0tt
Skn0tt merged commit 9a10128 into microsoft:main Jul 23, 2026
29 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants