"Freeze" data classes and routes + some slotting fixes/refactor #611
Closed
FasterSpeeding wants to merge 7 commits intohikari-py:masterfrom
Closed
"Freeze" data classes and routes + some slotting fixes/refactor #611FasterSpeeding wants to merge 7 commits intohikari-py:masterfrom
FasterSpeeding wants to merge 7 commits intohikari-py:masterfrom
Conversation
davfsa
reviewed
May 15, 2021
* Replace some overkill attrs.define calls on pure abcs with explicitly declared empty slots * Add missing empty slots to some event abcs
…ring mutable state * There isn't really any good standard way to do this with mappings so for now dicts will still be used * Since we type as Sequence rather than MutableSequence or List this is esxsentially a free change as far as our public interface is concerned
4e1273d to
349b4e2
Compare
Member
|
Btw, exceptions shouldnt be frozen, right? |
Contributor
Author
|
Gonna close this for now, since python-attrs/attrs#817 likely brings back the performance difference between default parameter define and default parameter frozen classes |
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.
Summary
Turns out previous assumptions on performance implications of freezing attr data classes were incorrect and the documentation on https://www.attrs.org/en/stable/how-does-it-work.html?highlight=frozen#slotted-classes is misleading. While frozen slotted classes are slower to initiate than frozen dict classes, there isn't any difference between frozen slotted classes and non-frozen slotted classes as far as this goes.
Other features this PR introduces
Removals
object.__setattr__(new_guild, "field_name", old_state)but that'd be unorthodox at best)Changes this PR doesn't introduce but marks as TODO:
Barely in scope fixes/changes introduced
Checklist
noxand all the pipelines have passed.Related issues