Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve union encoding performance #194

Merged
merged 5 commits into from
Mar 9, 2024
Merged

Improve union encoding performance #194

merged 5 commits into from
Mar 9, 2024

Conversation

Fatal1ty
Copy link
Owner

@Fatal1ty Fatal1ty commented Feb 26, 2024

Currently, we have to wrap int and float values on serialization with int(...) and float(...). This is used as a hack for poor union serialization logic which is based on applying an encoding operation for each type in the list until we get the first result without errors. If we have a value of type Union[int, DataClassA] then without applying int(value) (which will obviously fail on instances of DataClassA) we would pass instances of DataClassA as is because int is on the first place.

In this PR union serialization logic is changed so that we check the type of a value with pass-through strategy before returning it as is. It allows us to remove a hack for int and float and not try to perform encoding operations that are known to fail.

This pull request fixes the following issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant