I have the following code:
@overload
def compressible_geometry(geometry: _GeomT, /) -> _GeomT: ...
@overload
def compressible_geometry(geometry: NDArray[np.float64], /) -> NDArray[np.float64]: ...
def compressible_geometry(
geometry: _GeomT | NDArray[np.float64], /
) -> _GeomT | NDArray[np.float64]:
"""
Make geometry easily compressible by reducing mentissa noise.
It is then necessary to round the coordinates back.
Inspired by http://www.danbaston.com/posts/2018/02/15/optimizing-postgis-geometries.html
"""
if isinstance(geometry, BaseGeometry):
return transform(geometry, compressible_geometry)
view = geometry.view(np.uint64)
view &= _MASK
return geometry
And performance analysis indicate:

That only 17 seconds from 66 seconds total, is the implementation of transform. The remaining time is taken by the deprecate_positional decorator.