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

Antoine Pitrou report at bugs.python.org
Thu Sep 19 16:02:21 CEST 2013


Antoine Pitrou added the comment:

> The point is that your patch breaks functions like gettotalsizeof().
> It makes impossible to get a total size of general object.

The thing is, "Total size" is generally meaningless. It can include
things such as the object's type, or anything transitively referenced
by the object, such as modules.

> It will be better to add gettotalsizeof() to the stdlib (or add an
> optional parameter to sys.getsizeof() for recursive counting).

This patch has *nothing* to do with recursive counting. It counts
the internal arrays of itertools.tee() as part of its memory size,
which is reasonable and expected. It does *not* count memory recursively:
it doesn't count the size of the itertools.tee()'s cached objects,
for example.

Recursive counting doesn't make sense with Python. Where do you stop
counting?

----------

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


More information about the Python-bugs-list mailing list