Python's Data Containers Comparison

Posted on Thu 24 August 2023 in python

With Python 3.7 data classes have been introduced. They are simple classes that can hold some data as attributes, support type hints in a clean way, and provide a default constructor for developers. Good news! they can be immutable (frozen). I know the dataclasses lib provides much more features …


Continue reading

Respect __init__ to reduce your memory usage

Posted on Tue 20 June 2023 in python

Recently I was playing with some data using my beloved Python, and during transforming the records I found out that CPython can optimize the memory usage of created objects of the same class in a very interesting way.

I think most Python developers are familiar with __slots__, we mostly use …


Continue reading