One carries the entire feature set of the python runtime, the other is compiled.
for poly in polygon_subset:
if np.linalg.norm(poly.center - point) < max_dist:
close_polygons.append(poly)
I don't think the entire feature set of the Python runtime is involved in this.No, it's a LOAD_FAST bytecode instruction. (The other stuff is mostly right, and probably contributes.)