numpy数组及处理:效率对比
2021-06-16 22:05
标签:append port http numpy image lis 数组 dde .com numpy数组及处理:效率对比 标签:append port http numpy image lis 数组 dde .com 原文地址:https://www.cnblogs.com/zwlh/p/9722965.htmla=list(range(10))
b=list(range(0,50,5))
c=[]
for i in range(len(a)):
c.append(a[i]**2+b[i]**3)
print(a,b,c)
def pySum(n):
a=list(range(n))
b=list(range(0,5*n,5))
c=[]
for i in range(len(a)):
c.append(a[i]**2+b[i]**3)
return (c)
print(pySum(10))
import numpy
def nySum(n):
a=numpy.arange(n)
b=numpy.arange(n)
c=a**2+b**3
return (c)
from datetime import datetime
print(nySum(10))
from datetime import datetime
start=datetime.now()
pySum(100000)
timeddelta=datetime.now()-start
print(timeddelta)
start=datetime.now()
nySum(100000)
timeddelta=datetime.now()-start
print(timeddelta)