Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix WKB writing on big-endian systems
`shapely.to_wkb` (called in `pyogrio.geopandas.write_dataframe` via `geopandas.array.to_wkb`) defaults to machine byte order, so simply reading the first byte (of a 4-byte integer geometry type) is broken on big-endian machines. And since some geometry type could be 2 bytes, this also seems broken on little-endian machines, though I did not check if any 2-byte types could be produced. The commented-out code here indicates the correct course of action (reading the first byte to determine byte order). Instead of using `int.from_bytes`, I wrote it out as bitshifting operations, which compile directly to 1 or 2 (if byte swapping) assembly instructions. Also, change `wkb_buffer` to be `const`, as it doesn't need to be writeable (and perhaps this will save a copy.)
- Loading branch information