Skip to content

Speed up getfuncargnames for plain functions#3

Open
adamtheturtle wants to merge 1 commit into
mainfrom
adamtheturtle/faster-collect-getfuncargnames
Open

Speed up getfuncargnames for plain functions#3
adamtheturtle wants to merge 1 commit into
mainfrom
adamtheturtle/faster-collect-getfuncargnames

Conversation

@adamtheturtle

@adamtheturtle adamtheturtle commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fast-path getfuncargnames for plain Python functions via __code__, skipping inspect.signature().

Timing (pytest's own testing/ suite)

Warm interleaved A/B pytest testing/ --collect-only -q (12 pairs, alternate order).

Median
main 0.860s
This change 0.845s
Delta +0.015s (+1.7%)

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. Larger synthetic suites show clearer wins.

Test plan

  • testing/python/fixtures.py getfuncargnames tests

Avoid inspect.signature() on the common path by reading argument names from
__code__, which dominates getfuncargnames cost during large-suite collection.

Co-authored-by: Cursor <cursoragent@cursor.com>
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