3 ms·
Per the Python 3 docs (for some reason not in the Python 2 docs, but the same holds): "Only the memory consumption directly attributed to the object is accounte
by benhoyt 13y ago
Per the Python 3 docs (for some reason not in the Python 2 docs, but the same holds): "Only the memory consumption directly attributed to the object is accounted for, not the memory consumption of objects it refers to."
Most of the space for the NonSlotted version is in the __dict__, and if you print the size of ni.__dict__ you'll probably get a couple of hundred bytes.
There are better, recursive ways to get the real size of a Python object in memory, for example see: http://pythonhosted.org/Pympler/asizeof.html#asizeof http://pythonhosted.org/Pympler/asizeof.html#asizeof
- omegote 13y agoNice, just used pympler.asizeof and it reported that the slotted version has about 22% of the size of the non-slotted version.