问题 following up on another question import numpy as np repeat=int(1e5) r_base = np.linspace(0,4,5) a_base = 2 np.random.seed(0) r_mat = r_base * np.random.uniform(0.9,1.1,(repeat,5)) a_array = a_base * np.random.uniform(0.9,1.1, repeat) # original slow approach def func_vetorized_level1(r_row, a): if r_row.mean()>2: result = np.where((r_row >= a), r_row - a, np.nan) else: result = np.where((r_row >= a), r_row + a, 0) return result # try to broadcast this func to every row of r_mat using list