perf: Speed up unit tests via fixture scoping and reduced filesystem I/O#82
Merged
perf: Speed up unit tests via fixture scoping and reduced filesystem I/O#82
Conversation
- Add session-scoped config fixture for read-only tests in test_default.py - Early-exit os.walk in Config.push() — stop after first config file found - Cache os.listdir in RecursiveConfig to eliminate redundant stat calls - Reduces test suite time from ~6s to ~3.5s (40% faster) Closes #81 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reduces PyAutoConf test suite time by ~40% through three targeted optimizations:
os.walkinConfig.push()(stops after first config file match)os.listdirinRecursiveConfig(replaces 4 stat calls per lookup with set membership check)All 71 tests pass. Downstream suites verified: PyAutoGalaxy (852 passed), PyAutoLens (286 passed).
API Changes
None — internal changes only. The public API of
Config,RecursiveConfig, and all other classes is unchanged. The optimizations only affect internal filesystem access patterns.Test Plan
Full API Changes (for automation & release notes)
Removed
(none)
Added
RecursiveConfig.listingproperty — cachedos.listdirresult (internal, not public API)Changed Behaviour
Config.push()— validation walk now exits early on first config file match instead of collecting all suffixes. Same error raised for invalid paths.RecursiveConfig._getitem()— uses cached directory listing instead of individual stat calls. Same lookup semantics.Migration
No migration needed — all changes are internal.
🤖 Generated with Claude Code