You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
This PR optimizes the ObjectType initialization by an order of magnitude by leveraging the same strategy that dataclasses introduced (dynamic creation of optimal __init__ functions based on eval).
Also the breaking change could be quite a big one. Can you give an example of a custom init method that would let you define private attributes?
You can overwrite your __init__ allowing the extra private fields. There is a hacky solution we can get to skip the breaking change, but I think a better long-term solution is just removing it's support and focusing on documentation.
After thinking on it a bit more, I think we can test the water by merging the PR and seeing if anyone has significant issues over the breaking change. So we should be good to merge! YAY!
Hi,
just a thought - could this change be backported to v2? From a quick glance it looks like the changed code is almost identical to what's in v2.
I'm not sure whether there are some other changes elsewhere on which this depends on.
Thanks!
EDIT: just tested applying the change against v2 and it works fine. 307 kops/s -> 1454 kops/s. The change doesn't have a significant effect on the response time in my case though.
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.
This PR optimizes the ObjectType initialization by an order of magnitude by leveraging the same strategy that dataclasses introduced (dynamic creation of optimal
__init__
functions based on eval).Benchmarks
This are the benchmarking numbers after running:
Before this patch (385,925 operations / second)
After this patch (1,270,600 operations / second) - More than 3x speedup
Breaking change
This PR introduces a breaking change, private attributes (aka:
_*
fields) would not be automatically modified on instantiation.Note: DO NOT MERGE YET