Repository navigation
Conversation
The JSON converter used a `transfer_type_convertible` converter only at the top level of a payload, so such a value in a list or a dataclass field failed to encode. A nested dataclass is still written as fields. The lookup runs after the primitive checks, so it doesn't slow them.
moetemp
force-pushed
the
moe/brook/review/g2-nested-transfer-types
branch
from
October 28, 2026 07:54
7d10c5a to
480f581
Compare
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 was changed
This PR makes the JSON converter convert transfer type values that are nested in a JSON value, such as a list item or a dataclass field. The extra lookup costs about 3% on a decode of many small dataclasses.
NestedValue[int]whole.Why?
Today the converter runs only at the top level of a payload, so a nested transfer type value fails to encode. Stream handles (#373) are the first users, and big-payload handles may be next. Stream handles and big-payload handles has the discussion.
Part of the Brook review series.
Checklist
test_transfer_type_values_nested_in_json,test_proto_transfer_type_nested_in_json_is_its_proto_jsonandtest_transfer_type_dataclass_in_a_top_level_list_keeps_its_fieldsintests/test_converter.py.