2
見的代碼:爲什麼不能objgraph捕獲np.array()的增長?
import objgraph
import numpy as np
objgraph.show_growth()
j = 20
y = []
for i in range(5):
for l in range(j):
y.append(np.array([np.random.randint(500),np.random.randint(500)]))
print 'i:',i
objgraph.show_growth()
print '___'
#objgraph.show_most_common_types(limit=100)
j += 1
結果是:
i: 1
wrapper_descriptor 1596 +3
weakref 625 +1
dict 870 +1
method_descriptor 824 +1
i: 2
i: 3
i: 4
對於2,3和4時期,它示出了沒有任何成長。但它應該顯示numpy.array的數量增長
我的猜測是你需要學習'objgraph'文檔來了解它可以檢測到什麼,不能檢測到。並掃描其他'objgraph' SO問題。 「numpy」應用程序並不多。 – hpaulj