You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
⚡️ Speed up method CfoVisitor._is_codeflash_output_target by 76% in PR #358 (fix-test-reporting)
Here is an optimized rewrite of your program with a focus on improving performance in the `_is_codeflash_output_target` method.
These changes focus on avoiding unnecessary generator creation, reducing function calls, and using faster data structures and comparison strategies.
**Key optimizations:**
- Use `type(...) is ...` instead of `isinstance()` for frequently called type checks for speed.
- Unroll the `any(...)` generator over `target.elts` into an explicit for loop to reduce function call and overhead in the hot path.
- Avoid recursive generator creation where possible; use explicit returns.
- Avoid `isinstance(..., (a, b))` for hot paths (for small type hierarchies and known types); it's slightly faster to compare types directly.
These micro-optimizations especially benefit scenarios with large ASTs or heavy tuple/list unpackings.
The function's logic and return value are identical to your original version.
0 commit comments