numpy数组及处理:效率对比

2021-06-17 01:04

阅读:604

标签:int   class   .com   inf   image   对比   分享   处理   nump   

def pySum(n):
    a = list(range(n))
    b = list(range(0,3*n,3))
    c = []
    for i in range(len(a)):
        c.append(a[i]**2+b[i]**3)
    return c


import numpy
def nySum(n):
    a = numpy.arange(n)
    b = numpy.arange(0,3*n,3)
    c = a**2 + b**3
    return c

import datetime
start = datetime.datetime.now()
pySum(200000)
delta = print(datetime.datetime.now()-start)

start1 = datetime.datetime.now()
nySum(200000)
delta = print(datetime.datetime.now()-start1)

技术分享图片

numpy数组及处理:效率对比

标签:int   class   .com   inf   image   对比   分享   处理   nump   

原文地址:https://www.cnblogs.com/hodafu/p/9722916.html


评论


亲,登录后才可以留言!