Message166147
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 |
|
Date |
User |
Action |
Args |
2012-07-22 16:22:41 | Pankrat | set | recipients:
+ Pankrat |
2012-07-22 16:22:41 | Pankrat | set | messageid: <1342974161.65.0.374402048104.issue15424@psf.upfronthosting.co.za> |
2012-07-22 16:22:41 | Pankrat | link | issue15424 messages |
2012-07-22 16:22:40 | Pankrat | create | |
|