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
{{ message }}
Repository navigation
PERF: __slots__ not declared consistently, negating some memory savings #45124
I have checked that this issue has not already been reported.
I have confirmed this issue exists on the latest version of pandas.
I have confirmed this issue exists on the master branch of pandas.
Reproducible Example
👋 Hello there!
I've found quite some classes declaring __slots__ whose bases classes do not. This negates some of the performance benefits. Fixing this should be a relatively easy performance win.
After some experimentation I've found it's not quite as easy as adding __slots__ = () to the bases classes. But, it should still be relatively simple.
On python 3.11+, slots savings are reduced (regular objects got a lot more performant)
In an inheritance tree, either use __slots__ everywhere, or not at all. Mixing __slots__ and non-__slots__ classes through inheritance can lead to performance issues
Activity
ariebovenberg commentedon Dec 30, 2021
take
jbrockmendel commentedon Mar 22, 2026
I'm skeptical this is worth the bother.
ariebovenberg commentedon Mar 22, 2026
@jbrockmendel you're probably right.
Since posting this issue I've done a deep investigation of
__slots__benefits. I even presented a talk at EuroPython about it.The tl;dw is:
__slots__everywhere, or not at all. Mixing__slots__and non-__slots__classes through inheritance can lead to performance issues