-
-
Notifications
You must be signed in to change notification settings - Fork 365
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
Warning in docs about frozen classes no longer applicable #816
Comments
Ooph, I was not aware of this. A fast path would be great here. |
Yeah fast path is definitely the way here. I'm surprised there isn't one – I suspect I just forgot to implement it. |
hynek
added a commit
that referenced
this issue
May 16, 2021
This is important because define/mutable have on_setattr=setters.validate on default. Fixes #816
hynek
added a commit
that referenced
this issue
May 16, 2021
This is important because define/mutable have on_setattr=setters.validate on default. Fixes #816
hynek
added a commit
that referenced
this issue
May 16, 2021
This is important because define/mutable have on_setattr=setters.validate on default. Fixes #816 Signed-off-by: Hynek Schlawack <hs@ox.cx>
hynek
added a commit
that referenced
this issue
May 16, 2021
This is important because define/mutable have on_setattr=setters.validate on default. Fixes #816 Signed-off-by: Hynek Schlawack <hs@ox.cx>
hynek
added a commit
that referenced
this issue
May 17, 2021
* Optimize the case of on_setattr=validate & no validators This is important because define/mutable have on_setattr=setters.validate on default. Fixes #816 Signed-off-by: Hynek Schlawack <hs@ox.cx> * Grammar
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you check the docs on frozen classes (https://www.attrs.org/en/stable/how-does-it-work.html#immutability), you'll note it says "You should avoid instantiating lots of frozen slotted classes [...] in performance-critical code."
However... with
attr.define
/attr.frozen
both take the same amount of time.What's up? Well, turns out the new API is setting
on_setattr=attr.setters.validate
. This turns the__init__
from this: (old)To this: (new)
Possible solutions:
on_setattr=attr.setters.validate
in new API if there is a validator.The text was updated successfully, but these errors were encountered: