guppy3很容易使用.在代码中的某个位置,您必须编写以下内容:
from guppy import hpy
h = hpy()
print(h.heap())
这将为您提供如下所示的输出:
Partition of a set of 132527 objects. Total size = 8301532 bytes.
Index Count % Size % Cumulative % Kind (class / dict of class)
0 35144 27 2140412 26 2140412 26 str
1 38397 29 1309020 16 3449432 42 tuple
2 530 0 739856 9 4189288 50 dict (no owner)
您还可以从引用对象的位置找到相关的统计信息,但不知何故,这些对象上的文档有点稀疏.
还有一个用Tk编写的图形浏览器.
对于Python 2.x、 使用Heapy.