This repository has been archived by the owner on Dec 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 286
Optionally use __slots__ for payload members #259
Open
misakwa
wants to merge
12
commits into
Thriftpy:develop
Choose a base branch
from
misakwa:fix/optimize-payload
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains 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
- Expose using slot based generated code to load entry points - Add first tests - TODO: - Fix possible cache poisoning when loading slot vs no slot structs - Add tests for above - Add pickling tests for slot based structs
There are still a few questions and some cleanup to be done, but I think this should get the conversation started. |
- Replace class with a newer one with slot fields - Implement subclass and instance checks
Feature accepted. Update this issue later. |
During the first creation of the loaded class with slots, a new class is inserted into the inheritance chain to ensure that the slot fields are defined. This is done because of the need to create an empty struct during the parsing phase and fill it in later - slots require the fields to be known before hand. All checks on the new replacement class will have it looking like the original except an equality comparison between the replaced class and its replacement. >>> import thriftpy >>> ab = thriftpy.load('addressbook.thrift', use_slots=True) >>> ab_inst = ab.AddressBook() >>> ab_inst.__class__ == ab.AddressBook # will return False >>> # all other checks should work as expected >>> isinstance(ab_inst, ab.AddressBook) # will return True >>> issubclass(ab_inst.__class__, ab.AddressBook) # will return True In order to get pickling to work as expected, a new extension type is registered with copyreg (copy_reg for py2x) to avoid pickling errors.
I have updated the implementation to support all types of objects as well as the recursive case. The service args and results are now created with slots as well. |
misakwa
force-pushed
the
fix/optimize-payload
branch
from
November 22, 2016 12:58
ba74089
to
afd9acd
Compare
misakwa
force-pushed
the
fix/optimize-payload
branch
from
November 22, 2016 13:37
7f3f6bd
to
682e191
Compare
This is now ready for review. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #198