Skip to content

Instantly share code, notes, and snippets.

@wenweixu
Created February 19, 2020 19:54
Show Gist options
  • Save wenweixu/7cba46585c9dae9406219da8fa68ece6 to your computer and use it in GitHub Desktop.
Save wenweixu/7cba46585c9dae9406219da8fa68ece6 to your computer and use it in GitHub Desktop.
def myf(r,c):
return r+c
f = np.vectorize(myf)
r_arr = np.meshgrid(range(10000),range(10000))
c_arr = np.meshgrid(range(10000),range(10000))
start = time.time()
z_arr = f(r_arr, c_arr)
print(time.time() - start)
@KosayJabre
Copy link

KosayJabre commented Mar 19, 2021

With imports:

import time
import numpy as n


def myf(r,c):  
    return r+c

f = np.vectorize(myf)

r_arr = np.meshgrid(range(10000),range(10000))
c_arr = np.meshgrid(range(10000),range(10000))

start = time.time()

z_arr = f(r_arr, c_arr)

print(time.time() - start)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment