def function_map(samplez, zfit):
    diff = zfit[:, :-1] - zfit[:, 1:]

def _fuc1(x):
    a = x - zfit
mask = np.ma.masked_array(a)
mask[a <= 0] = np.ma.masked
index = mask.argmin(axis=1)
d = zfit[:, (index)]
f = (x - d) / diff[:, (index)]
return index, f
result = map(_fuc1, samplez)
return np.array([item[1] for item in result]), np.array([item[0] for item in
    result])
Эффективность с очень большими массивами numpy