mirror of
https://github.com/astral-sh/ruff.git
synced 2026-11-21 12:16:15 +08:00
## Summary Checking Home Assistant’s Anthropic integration took 283.1 ms before this change and 252.6 ms after (10.8% less time, with a 95% paired interval of 7.8–13.7% less). Each of 24 blocks ran `ty check homeassistant/components/anthropic` twice with the baseline build and once with the changed build, in balanced, randomized order. All runs emitted the same 41 lines of diagnostics. The full Home Assistant timings did not resolve this patch’s individual contribution. The Anthropic SDK’s synchronous and asynchronous streaming functions each test 53 event names in one `or` expression. At each operand, ty used to reapply every condition leading up to it, recording 1,378 conditions per expression. The continuation already carries those earlier conditions, so adding just the preceding operand’s condition brings the count down to 52. Checking a file that imports the two original function bodies went from 95.9 ms to 19.3 ms. Changing just those two `or` chains to tuple membership checks made both builds take about 12 ms. Toggling prefix replay in a single release executable also reproduced the integration improvement (270.1 ms to 237.5 ms). An assignment expression (`:=`) can introduce a new binding partway through a chain. Those chains keep the earlier conditions so the reassigned name gets the same reachability information.