This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Pankrat
Recipients Pankrat
Date 2012-07-22.16:22:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1342974161.65.0.374402048104.issue15424@psf.upfronthosting.co.za>
In-reply-to
Content
If sys.getsizeof is called on an array, the result doesn't include the size of the items: 

>>> from array import array
>>> a = array("i", [0] * 100000)
>>> a.__sizeof__()
40

While this makes sense for a list, an array doesn't have separate referents that could be sized:

>>> import gc
>>> gc.get_referents(a)
[]

The attached patch adds an implementation of the __sizeof__ method for arrays that includes the size of the buffer for the elements.

It would be great if the patch would be considered for one of the upcoming versions of Python.

Thanks, Ludwig
History
Date User Action Args
2012-07-22 16:22:41Pankratsetrecipients: + Pankrat
2012-07-22 16:22:41Pankratsetmessageid: <1342974161.65.0.374402048104.issue15424@psf.upfronthosting.co.za>
2012-07-22 16:22:41Pankratlinkissue15424 messages
2012-07-22 16:22:40Pankratcreate