[issue19048] itertools.tee doesn't have a __sizeof__ method

Serhiy Storchaka report at bugs.python.org
Fri Sep 20 02:29:42 CEST 2013


Serhiy Storchaka added the comment:

Here is advanced function which counts only objects on which there are no external references.

>>> import itertools
>>> a, b = itertools.tee(range(10000))
>>> max(zip(a, range(100)))
(99, 99)
>>> sys.getsizeof(a)
32
>>> gettotalinnersizeof(a)
32
>>> gettotalinnersizeof(b)
292
>>> gettotalinnersizeof(a, b)
608

Total size of a and b is larger than a sum of sizes of a and b. It's because it includes size of one shared between a and teedataobject and one shared range iterator.

----------
Added file: http://bugs.python.org/file31822/gettotalsizeof.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19048>
_______________________________________


More information about the Python-bugs-list mailing list