Skip to content

perf: speed up Python stack capture - #3147

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

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

Conversation

@Skn0tt

@Skn0tt Simon Knott (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
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