5 ms·
The time is spent in this 3-line loop: for poly in polygon_subset: if np.linalg.norm(poly.center - point) < max_dist: close_polygons.ap
by FreeHugs 3y ago
The time is spent in this 3-line loop:
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.
- ben-schaaf 3y agoWithout using every feature you still have to conform to the complexity of the runtime. Every variable in that loop is a hash map lookup into the locals. `np.linalg.norm` is two field accesses, necessitating more hash map lookups on the module objects. `-` and `<` are attribute lookups as well as full function calls.
- wizzwizz4 3y ago> Every variable in that loop is a hash map lookup into the locals. No, it's a LOAD_FAST bytecode instruction. (The other stuff is mostly right, and probably contributes.)