Fast Google Polyline Encoding and Decoding
Installation
uv add pypolyline
pip install pypolyline
Installing for local development
- Ensure you have a Rust toolchain installed
- run
uv sync --dev(this builds the extension using maturin) - run
uv run pytest
Changes to Cargo.toml, Cargo.lock, or any .rs file will bust the cache, triggering a rebuild when uv commands are run.
Supported Python Versions
All currently supported Python versions.
Binary wheels target the CPython Stable ABI (abi3): a single abi3 wheel per platform covers CPython 3.11 and later.
Supported Platforms
- Linux (
manylinux*-compatible, x86_64 and aarch64) - macOS (x86_64 and arm64)
- Windows 64-bit
Usage
Coordinates must be in (Longitude, Latitude) order, and can be any sequence of (x, y) pairs, or an (N, 2) NumPy array (or any other object supporting the buffer protocol). Polylines can be bytes or str. NumPy is not required.
from pypolyline.cutil import encode_coordinates, decode_polyline
coords = [
[52.64125, 23.70162],
[52.64938, 23.70154],
[52.64957, 23.68546],
[52.64122, 23.68549],
[52.64125, 23.70162]
]
# precision is 5 for Google Polyline, 6 for OSRM / Valhalla
polyline = encode_coordinates(coords, 5)
# polyline is 'ynh`IcftoCyq@Ne@ncBds@EEycB'
decoded_coords = decode_polyline(polyline, 5)
Error Handling
- Failure to encode coordinates, or to decode a supplied Polyline, will raise a
RuntimeErrorcontaining information about the invalid input. - A precision other than 5 or 6, or coordinates that aren't
(N, 2), will raise aValueError. - A Polyline that isn't
bytesorstrwill raise aTypeError.
How it Works
PyO3 bindings to the Rust polyline crate. The GIL is released while encoding and decoding.
Is It Fast
…Yes.
You can verify this by installing the polyline package, then running benchmarks.py, a calibrated benchmark using cProfile.
On an M2 MBP, The pure-Python test runs in ~2500 ms, the Flexpolyline benchmark runs in ~1500 ms and the Rust benchmark runs in around 80 ms (30 x and 17.5 x faster, respectively).
License
The Blue Oak Model Licence 1.0.0
Citing Pypolyline
If Pypolyline has been significant in your research, and you would like to acknowledge the project in your academic publication, we suggest citing it as follows (example in APA style, 7th edition):
Hügel, S. (2021). Pypolyline (Version X.Y.Z) [Computer software]. https://doi.org/10.5281/zenodo.5774925
In Bibtex format:
@software{Hugel_Pypolyline_2021,
author = {Hügel, Stephan},
doi = {10.5281/zenodo.5774925},
license = {MIT},
month = {12},
title = {{Pypolyline}},
url = {https://github.com/urschrei/simplification},
version = {X.Y.Z},
year = {2021}
}
Metadata
Release files for pypolyline 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pypolyline-1.0.0.tar.gz | 23.9 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| pypolyline-1.0.0-cp311-abi3-win_amd64.whl | CPython 3.11 | abi3 | Windows x86-64 | Details |
| pypolyline-1.0.0-cp311-abi3-manylinux_2_28_x86_64.whl | CPython 3.11 | abi3 | Linux glibc 2.28+ x86-64 | Details |
| pypolyline-1.0.0-cp311-abi3-manylinux_2_28_aarch64.whl | CPython 3.11 | abi3 | Linux glibc 2.28+ ARM64 | Details |
| pypolyline-1.0.0-cp311-abi3-macosx_11_0_x86_64.whl | CPython 3.11 | abi3 | macOS 11.0+ x86-64 | Details |
| pypolyline-1.0.0-cp311-abi3-macosx_11_0_arm64.whl | CPython 3.11 | abi3 | macOS 11.0+ ARM64 | Details |
Total release size: 930.8 kB
Release files / pypolyline-1.0.0.tar.gz
| Download URL | pypolyline-1.0.0.tar.gz |
|---|---|
| Size | 23.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
101b7742df62d9ef26f08f3944083d7d806be3ee869333380502fd4d0ff62bc1
|
|
BLAKE2b-256 checksum How to use checksums |
809f465e894648b76faaa0c27cd245c649b57172ecbabea2968c7499b5f15038
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.
Transparency logRelease files / pypolyline-1.0.0-cp311-abi3-win_amd64.whl
| Download URL | pypolyline-1.0.0-cp311-abi3-win_amd64.whl |
|---|---|
| Size | 122.9 kB |
| Tags | CPython 3.11 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
d91db82684c7e4206361f6385213e88f35f8c635dd647cd091deeb1c6d85ab47
|
|
BLAKE2b-256 checksum How to use checksums |
801547e9e23732861afab9faa85fd54c1c60f74cbf000203ca5b10172f53ed7d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.
Transparency logRelease files / pypolyline-1.0.0-cp311-abi3-manylinux_2_28_x86_64.whl
| Download URL | pypolyline-1.0.0-cp311-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 203.0 kB |
| Tags | CPython 3.11 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
e912a7d4132cf5016447a66be5d37a2df99056b5a943e2b21ec27b4d7c6e2042
|
|
BLAKE2b-256 checksum How to use checksums |
ef7c80d30ce272681ea28d72b7c77da71776a4f8cdc3f435a22112dc7dd77d82
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.
Transparency logRelease files / pypolyline-1.0.0-cp311-abi3-manylinux_2_28_aarch64.whl
| Download URL | pypolyline-1.0.0-cp311-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 194.2 kB |
| Tags | CPython 3.11 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
98991621473d2edd2b283a141015eca31c0c6bd3f9245018c08dee10d7653be3
|
|
BLAKE2b-256 checksum How to use checksums |
65e7addf6b4177c8688178fa30bcb6783d14c949333aeb84bc49a21bbfae3dc7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.
Transparency logRelease files / pypolyline-1.0.0-cp311-abi3-macosx_11_0_x86_64.whl
| Download URL | pypolyline-1.0.0-cp311-abi3-macosx_11_0_x86_64.whl |
|---|---|
| Size | 198.1 kB |
| Tags | CPython 3.11 abi3 macOS 11.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
aa6427f7e6966277e7b94d453ecdbabb8aefc37cd8e81941db612f27289db892
|
|
BLAKE2b-256 checksum How to use checksums |
d23f208de948b301af8f1c5a5806a343bd09dec6f04a876911dbe1706fd59c70
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.
Transparency logRelease files / pypolyline-1.0.0-cp311-abi3-macosx_11_0_arm64.whl
| Download URL | pypolyline-1.0.0-cp311-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 188.7 kB |
| Tags | CPython 3.11 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
3436ef1f79a64daf76b10b8b076dc24af155d069ab287fdb0d772db815f4e8c6
|
|
BLAKE2b-256 checksum How to use checksums |
be845c1eb679ca52210782b7186183ddb1967d3788495f443e8f5154ebb4389b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.
Transparency log