Skip to content

Reuse parsed traceback source ASTs within a session - #15210

Closed
DeviousCardi wants to merge 2 commits into
pytest-dev:mainfrom
DeviousCardi:fix/session-source-cache-13360
Closed

DeviousCardi wants to merge 2 commits into
pytest-dev:mainfrom
DeviousCardi:fix/session-source-cache-13360

Conversation

@DeviousCardi

@DeviousCardi DeviousCardi commented Oct 19, 2026 •

Copy link
Copy Markdown

Repeated failures in a large module reparse the same source for each traceback. This reuses parsed ASTs within a session, with a bounded cache that invalidates changed source and is cleared during cleanup.

Closes #13360. Regression tests cover source changes, nested runs and cleanup. All 4,705 tests passed; local failure-heavy benchmarks improved 2.7–5.1×.

Written by Codex.

Share a bounded source-validated cache between exception reports to avoid repeatedly parsing large modules with many failures. Restore the previous context during config cleanup so nested and failed sessions do not leak their active cache.

Co-authored-by: OpenAI Codex <noreply@openai.com>
@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Oct 19, 2026
@DeviousCardi

Copy link
Copy Markdown
Author

Added the missing no-session/no-caller-cache path to the existing traceback test in 88586f6. It now checks that an uncached lookup returns the same source as a lookup with a caller-owned cache. All 255 focused tests pass (11 skips), and file pre-commit checks, including mypy, pass. Local branch coverage now exercises that path; Codecov will confirm the combined patch result on CI.

@RonnyPfannschmidt

Copy link
Copy Markdown
Member

unattended agent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Quadratic runtime - O(n*n), n = number of tests

2 participants