Serhiy Storchaka added the comment: Thy are visible by calling gc.get_referents(). High-level function can use this to count recursive size of objects.
>>> import sys, gc, itertools >>> def gettotalsizeof(*args, seen=None): ... if seen is None: ... seen = {} ... sum = 0 ... for obj in args: ... if id(obj) not in seen: ... seen[id(obj)] = obj ... sum += sys.getsizeof(obj) ... sum += gettotalsizeof(*gc.get_referents(obj), seen=seen) ... return sum ... >>> a, b = tee(range(10000)) >>> sum(next(a) for i in range(1000)) 499500 >>> gettotalsizeof(a) 750 >>> gettotalsizeof(b) 18734 ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue19048> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com