-
Notifications
You must be signed in to change notification settings - Fork 27
Description
In geoarrow/geoarrow-rs#788 @b4l prototyped a custom implementation of writing to WKT, and he said
It is up to twice as fast as
wkt
andgeo
.
It doesn't look like this wkt
crate uses ryu
, and so I'm curious if that's a large part of why his implementation is faster. https://github.com/dtolnay/ryu seems to be a very popular library, and so it doesn't seem like an unreasonable dependency.
It looks like it should be relatively easy to swap in ryu
and test if that's significantly faster? It looks like
Lines 37 to 44 in c3088cd
write!(f, "{} {}", self.x, self.y)?; | |
if let Some(z) = self.z { | |
write!(f, " {}", z)?; | |
} | |
if let Some(m) = self.m { | |
write!(f, " {}", m)?; | |
} | |
Ok(()) |
I suppose the primary issue with using ryu is that ryu's Float
trait supports only f32
and f64
, while WktNum
supports a broader range of types, including integers.
Assuming that ryu is indeed quite a bit faster, I think it's worth special casing f32
and f64
if we can, assuming that most real world data will be f64
.
(For maintainability reasons, if geoarrow-rs can use wkt
directly, that's much more appealing to me than rolling our own).
Any thoughts?