-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Add __slots__
to all types and nodes
#11197
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
Conversation
Personally speaking I like this modification! |
Would you be able to provide some benchmarks? You might try running the daemon and use the |
I think that the main drawbacks are these:
I don't have a strong opinion, but catching invalid attribute assignments is somewhat nice during development and can save some time when debugging (but pretty rarely). What do others think? |
Since now
Totally.
I consider this as a benefit, actually 🙂
I hope more people will learn about this feature! Moreover, #10801 is now a thing. I personally love it! And I personally think it was more confusing for some types to have |
@ethanhs do you mean https://github.com/python/mypy/blob/3bdef9fe6d401f3d2e0cacf4964bd315550c3394/mypyc/test-data/run-bench.test or do you have any other specific benchmark in mind? |
It's easier to understand code structure with |
I was thinking you could just time running mypy on itself, but I didn't realize mypyc doesn't use slots, so it probably doesn't matter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like nobody is against this, so lets do it!
Using slots elsewhere may not be worth it, though, since mypyc basically gives all compiled classes an implicit __slots__
.
Quick review of changes:
self.
definitions, because class attributes and incompatible with__slots__
. This seems like a good idea for me, because there was no reason for them to be class-level. I can even imagine several bugs based on over-use of class-level attributes mutation. It might take more memory in some cases though.TODO
items toop: str
, it seems likeEnum
would be a better fit thereCloses #11195