python - Why does scipy linear interpolation run faster than nearest neighbor interpolation? -
i've written routine interpolates point data onto regular grid. however, find scipy 's implementation of nearest neighbor interpolation performs twice slow radial basis function i'm using linear interpolation ( scipy.interpolate.rbf ) relevant code includes how interpolators constructed if interpolation_mode == 'linear': interpolator = scipy.interpolate.rbf( point_array[:, 0], point_array[:, 1], value_array, function='linear', smooth=.01) elif interpolation_mode == 'nearest': interpolator = scipy.interpolate.nearestndinterpolator( point_array, value_array) and when interpolation called result = interpolator(col_coords.ravel(), row_coords.ravel()) the sample i'm running on has 27 input interpolant value points , i'm interpolating across 20000 x 20000 grid. (i'm doing in memory block sizes i'm not exploding computer btw.) below result of 2 cprofile s i've run on relevant code. note ...