看代码:
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
Run Code Online (Sandbox Code Playgroud)
结果是:
i: 1
wrapper_descriptor 1596 +3
weakref 625 +1
dict 870 +1
method_descriptor 824 +1
i: 2
i: 3
i: 4
Run Code Online (Sandbox Code Playgroud)
对于2,3和4时代,它没有显示任何增长.但它应该表明numpy.array的数量增长
我用它来实现神经网络。我更喜欢NumPy,因为用Python准备数据更方便;但是,我担心 NumPy 不如 C++ 库快。
您可以在9 8 7 6 5 4 3 2之间添加任何运算符(包括括号和+ - */**).例如,
98*76-5432*1=2016
9*8*7*(6+5-4-3)*(2-1)=2016
我写了一个像这样的程序
from __future__ import division
s = ['+','-','*','/','','(',')']
def calc(s):
a=s.split()
return eval(''.join(a))
a=['','9','','8','','7','','6','','5','','4','','3','','2','','1.','']
def test(tmp):
if tmp == 20:
try:
z = eval(''.join(a))
if z == 2016:
print ''.join(a)
except:
pass
return
for i in s:
#print a
a[tmp] = i
test(tmp+2)
for j in s:
a[0] = j
test(2)
Run Code Online (Sandbox Code Playgroud)
但这是不对的,因为数字之间可能存在多个运算符.