Repository navigation
MroDispatch resolves a value type's handlers once - #12
Merged
Merged
Conversation
handler_names_for walked the value type's MRO against every @Handles declaration on each call. A consumer's declarations and a value type's MRO are fixed at class creation, so the pair is resolved once and every dispatch reads it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XbFMSnLEc51gw21bLFFRK1
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.
What changes
MroDispatch.handler_names_forwalked the value type's whole MRO against every@handlesdeclaration on each call. Both sides are fixed when their classes are created, so the join is now resolved once per (consumer class, value type) and every dispatch reads it (resolved_handler_names). Each consumer class gets its own table in__init_subclass__, so a subclass that adds a handler never reads its parent's answers.handler_names_for,handler_forandhandlers_forkeep their signatures and results.Numbers
agent-comms dispatches every streamed Pi event through about ten
MroDispatchconsumers. ResolvingMessageUpdate(MRO depth 13) on each of its 697 consumer classes, 2,000 calls each:DurableTurn)That is roughly 30 ms of a one-message burst in agent-comms: small, and correct to remove.
Tests
tests/test_mro_dispatch.py: 10 passed. One new test: a subclass declared after its parent has already resolved a type still gets its own handlers, and the parent does not see them.🤖 Generated with Claude Code
https://claude.ai/code/session_01XbFMSnLEc51gw21bLFFRK1