Skip to content

Use ast.fix_missing_locations in assertion rewrite - #7

Closed
adamtheturtle wants to merge 0 commit into
mainfrom
adamtheturtle/faster-collect-assert-rewrite
Closed

adamtheturtle wants to merge 0 commit into
mainfrom
adamtheturtle/faster-collect-assert-rewrite

Conversation

@adamtheturtle

Copy link
Copy Markdown
Owner

Summary

  • Replace the pure-Python traverse_node location walk with ast.fix_missing_locations after seeding each rewritten statement from the assert.

Timing (pytest's own testing/ suite)

Warm interleaved A/B pytest testing/ --collect-only -q (8 pairs).

Median
main 0.520s
This change 0.545s
Delta -0.025s (-4.8%)

Collected 4286 tests each run.

Note: this suite is only ~4k tests / ~0.5–1.5s collect, so single micro-optimizations are often within run-to-run noise.

Test plan

  • testing/test_assertion.py

Made with Cursor

@adamtheturtle
adamtheturtle force-pushed the adamtheturtle/faster-collect-assert-rewrite branch from 9220559 to d3a6e94 Compare August 20, 2026 10:37
@adamtheturtle

Copy link
Copy Markdown
Owner Author

Closing: all changes from this PR were already included in #1 (merged). After rebasing onto main there was nothing left to merge.

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.

1 participant