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

Martin v. Löwis report at bugs.python.org
Thu Sep 19 20:06:32 CEST 2013


Martin v. Löwis added the comment:

> The problem is that that definition isn't helpful.
> If we ever change itertools.tee to use non-PyObjects internally, s
> suddenly its sys.getsizeof() would have to return much larger numbers 
> despite visible behaviour not having changed at all (and despite the 
> memory overhead being actually lower).

I see no problem with that. If the internal representation changes, nobody should be surprised if sizeof changes.

> I would hope it gives remotely useful information about the passed object.

It certainly does: it reports the memory consumption of the object itself, 
not counting the memory of other objects.

I proposed a precise definition of what "an other object" is. If you don't like it,
please propose a different definition that still allows to automatically sum up the
memory of a graph of objects.

----------

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


More information about the Python-bugs-list mailing list