pandas-dev / pandas

Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more
https://pandas.pydata.org
BSD 3-Clause "New" or "Revised" License
43.75k stars 17.96k forks source link

PERF: __slots__ not declared consistently, negating some memory savings #45124

Open ariebovenberg opened 2 years ago

ariebovenberg commented 2 years ago

Pandas version checks

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.

List of affected classes I could find:

pandas.core.internals.array_manager.BaseArrayManager
pandas.core.internals.array_manager.SingleArrayManager
pandas.core.internals.blocks.Block
pandas.core.internals.blocks.CategoricalBlock
pandas.core.internals.blocks.DatetimeLikeBlock
pandas.core.internals.blocks.NumericBlock
pandas.core.internals.blocks.ObjectBlock
pandas.core.internals.managers.BaseBlockManager
pandas.core.internals.managers.SingleBlockManager

Installed Versions

n/a

Prior Performance

No response

ariebovenberg commented 2 years ago

take