3 ms·
> and the equivalent dataclass is a mere 48 bytes > Although there seems to be some kind of trickery happening there, because if I make the class accept 3 floa
by masklinn 5y ago
> and the equivalent dataclass is a mere 48 bytes
> Although there seems to be some kind of trickery happening there, because if I make the class accept 3 floats instead of two, neither the class nor the instance get larger.
The dataclass stores stuff in a normal instance __dict__ and sys.getsize is not recursive.
namedtuples are variable-size instances, they store the attributes “inline”.