Settings

Theme

Show HN: Detect broken __slots__ in Python libraries

github.com

2 points by ariebovenberg 4 years ago · 1 comment

Reader

ariebovenbergOP 4 years ago

__slots__ is a good way to make Python classes more efficient. There is a catch though: you need to use it consistently in all base classes, or you don't get the full benefits. This is easy to forget, and there's nothing warning you if you mess up!

After fixing this in the `returns` library, I decided to create a tool `slotscheck` to detect this common problem anywhere.

I ended up finding broken slots in popular libraries, and even the stdlib. (see my blog post for the findings: https://dev.arie.bovenberg.net/blog/finding-broken-slots-in-...)

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection