Python Tip #298 (of 365): When creating lots of class instances, save memory wit...

@treyhunner@mastodon.social

Python Tip #298 (of 365):

When creating lots of class instances, save memory with __slots__.

class Point:
__slots__ = ("x", "y", "z")

def __init__(self, x, y, z):
(self.x, self.y, self.z) = (x, y, z)

๐Ÿงต (1/3)

#Python #DailyPythonTip