numpy数组及处理:效率对比

2021-06-16 22:05

阅读:461

标签:append   port   http   numpy   image   lis   数组   dde   .com   


a=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)

 


 

技术分享图片

 

numpy数组及处理:效率对比

标签:append   port   http   numpy   image   lis   数组   dde   .com   

原文地址:https://www.cnblogs.com/zwlh/p/9722965.html


评论


亲,登录后才可以留言!