Check the usage of __slots__.
Project description
Adding __slots__ to a class in Python is a great way to reduce memory usage. But to work properly, all subclasses need to implement it. It turns out it’s easy to forget one class in complex inheritance trees. What’s worse: there is nothing warning you that you messed up.
Until now!
Quickstart
Usage is quick from the command line:
slotscheck [MODULE]
For example:
$ slotscheck pandas
incomplete slots in 'pandas.core.internals.blocks.Block'
incomplete slots in 'pandas.core.internals.blocks.NumericBlock'
incomplete slots in 'pandas.core.internals.blocks.ObjectBlock'
incomplete slots in 'pandas.core.internals.array_manager.SingleArrayManager'
incomplete slots in 'pandas.core.internals.managers.SingleBlockManager'
incomplete slots in 'pandas.core.internals.array_manager.BaseArrayManager'
incomplete slots in 'pandas.core.internals.array_manager.SingleArrayManager'
incomplete slots in 'pandas.core.internals.blocks.Block'
incomplete slots in 'pandas.core.internals.blocks.CategoricalBlock'
incomplete slots in 'pandas.core.internals.blocks.DatetimeLikeBlock'
incomplete slots in 'pandas.core.internals.blocks.NumericBlock'
incomplete slots in 'pandas.core.internals.blocks.ObjectBlock'
incomplete slots in 'pandas.core.internals.managers.BaseBlockManager'
incomplete slots in 'pandas.core.internals.managers.SingleBlockManager'
Limitations
Even in the case that slots are not inherited properly, there may still an advantage to using them (i.e. attribute access speed and _some_ memory savings)
Only classes at module-level are checked (i.e. no nested classes)
In rare cases imports may fail, the module is then skipped. This is logged.
Installation
It’s available on PyPI.
pip install slotscheck
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for slotscheck-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77dab11b0ff5a04706c77e4f522c7e561821fb7ec73db97b4da57fb44f848b60 |
|
MD5 | 07423f3c86655113ba10b4d83889aa43 |
|
BLAKE2b-256 | f1136339e00561519de3d89f3a502cfa7c1c47bde34d1875748dc4d458125661 |