Tagged articles
2 articles
Page 1 of 1
MaGe Linux Operations
MaGe Linux Operations
Oct 12, 2020 · Fundamentals

How to Slash Python Memory Usage with __slots__ and Size Inspection

This article explains how Python's dynamic objects consume hidden memory, demonstrates measuring object sizes with sys.getsizeof and a recursive get_size function, and shows how using __slots__ can dramatically reduce memory footprints while discussing trade‑offs and practical code examples.

Memory ManagementPython__slots__
0 likes · 9 min read
How to Slash Python Memory Usage with __slots__ and Size Inspection
MaGe Linux Operations
MaGe Linux Operations
Oct 4, 2020 · Fundamentals

How Python’s __slots__ Can Slash Memory Usage by Up to 7×

This article explains why Python objects consume more memory than expected, demonstrates how to measure the true size of objects with a recursive get_size function, and shows that adding __slots__ to a class can dramatically reduce memory consumption while slightly improving performance.

Memory OptimizationPythonslots
0 likes · 9 min read
How Python’s __slots__ Can Slash Memory Usage by Up to 7×