Commit 2e4f0b3
committed
perf(shapes): vectorize datashader polygon scaling
The datashader path scaled polygons with a per-geometry affinity.scale loop
(_geometry[is_polygon].apply(lambda g: affinity.scale(...))) — a pure-Python
loop that dominates large polygon renders (measured ~60% of a 100k-polygon
render; the prototype's 33s at 1M is almost entirely this loop).
Replace with _scale_geometries: scale every coordinate about each geometry's
bounding-box centre (affinity.scale's default origin) in one vectorized pass
via shapely.get_coordinates/set_coordinates. Byte-identical to affinity.scale
including asymmetric shapes, multipolygons and holes (verified main-vs-branch,
diff_px=0); ~12x polygons / ~6.5x multipolygons -> ~2x+ end-to-end at 100k,
growing with n. Only fires for scale != 1.0.
The affine transform loop is left as-is (vectorizing it is ~0.9x: shapely
coordinate (de)serialization dominates, not the Python callback).1 parent 55f4970 commit 2e4f0b3
2 files changed
Lines changed: 43 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
593 | 593 | | |
594 | 594 | | |
595 | 595 | | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
596 | 610 | | |
597 | 611 | | |
598 | 612 | | |
| |||
820 | 834 | | |
821 | 835 | | |
822 | 836 | | |
823 | | - | |
824 | | - | |
825 | | - | |
826 | | - | |
| 837 | + | |
| 838 | + | |
827 | 839 | | |
828 | 840 | | |
829 | 841 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1978 | 1978 | | |
1979 | 1979 | | |
1980 | 1980 | | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
| 1985 | + | |
| 1986 | + | |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
| 2001 | + | |
| 2002 | + | |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
0 commit comments