We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
From the documentation for the collections module:
"Named tuple instances do not have per-instance dictionaries, so they are lightweight and require no more memory than regular tuples."
Python 3.4.0 (default, Apr 11 2014, 13:05:11) [GCC 4.8.2] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import pympler.asizeof >>> import collections >>> Point = collections.namedtuple('Point', ['x', 'y']) >>> p = Point(11, y=22) >>> p Point(x=11, y=22) >>> pympler.asizeof.asizeof(p) 1440 >>> t = 11, 22 >>> t (11, 22) >>> pympler.asizeof.asizeof(t) 128
I haven't been able to figure out the reason for the discrepancy.
The text was updated successfully, but these errors were encountered:
I believe Pympler assumes that the __dict__ property is part of the object and includes it in the given size:
__dict__
>>> print(asizeof.asized(p, detail=2).format()) Point(x=11, y=22) size=728 flat=32 __dict__ size=672 flat=576 [K] x size=32 flat=32 [K] y size=32 flat=32 [V] x: 11 size=16 flat=16 [V] y: 22 size=16 flat=16 __slots__ size=24 flat=24 __class__ size=0 flat=0 >>> p.__dict__ OrderedDict([('x', 11), ('y', 22)])
I'd have to check the namedtuple implementation in Python but it really sounds like a bug in Pympler's recursive sizing.
Sorry, something went wrong.
Fix sizing of named tuples (#10)
d1cd296
No branches or pull requests
From the documentation for the collections module:
"Named tuple instances do not have per-instance dictionaries, so they are lightweight and require no more memory than regular tuples."
I haven't been able to figure out the reason for the discrepancy.
The text was updated successfully, but these errors were encountered: