fastgeodesic 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,294 @@
1
+ # This file is autogenerated by maturin v1.16.0
2
+ # To update, run
3
+ #
4
+ # maturin generate-ci github --pytest -o .github/workflows/CI.yml
5
+ #
6
+ name: CI
7
+
8
+ on:
9
+ push:
10
+ branches:
11
+ - main
12
+ - master
13
+ tags:
14
+ - '*'
15
+ pull_request:
16
+ workflow_dispatch:
17
+
18
+ permissions:
19
+ contents: read
20
+
21
+ jobs:
22
+ linux:
23
+ runs-on: ${{ matrix.platform.runner }}
24
+ strategy:
25
+ matrix:
26
+ platform:
27
+ - runner: ubuntu-22.04
28
+ target: x86_64
29
+ - runner: ubuntu-22.04
30
+ target: x86
31
+ - runner: ubuntu-22.04
32
+ target: aarch64
33
+ - runner: ubuntu-22.04
34
+ target: armv7
35
+ - runner: ubuntu-22.04
36
+ target: s390x
37
+ - runner: ubuntu-22.04
38
+ target: ppc64le
39
+ steps:
40
+ - uses: actions/checkout@v6
41
+ - uses: actions/setup-python@v6
42
+ with:
43
+ python-version: "3.9"
44
+ - name: Build wheels
45
+ uses: PyO3/maturin-action@v1
46
+ with:
47
+ target: ${{ matrix.platform.target }}
48
+ args: --release --out dist
49
+ sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
50
+ manylinux: auto
51
+ - name: Build free-threaded wheels
52
+ uses: PyO3/maturin-action@v1
53
+ with:
54
+ target: ${{ matrix.platform.target }}
55
+ args: --release --out dist -i python3.14t
56
+ sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
57
+ manylinux: auto
58
+ - name: Upload wheels
59
+ uses: actions/upload-artifact@v6
60
+ with:
61
+ name: wheels-linux-${{ matrix.platform.target }}
62
+ path: dist
63
+ - uses: astral-sh/setup-uv@v7
64
+ if: ${{ startsWith(matrix.platform.target, 'x86_64') }}
65
+ - name: pytest
66
+ if: ${{ startsWith(matrix.platform.target, 'x86_64') }}
67
+ shell: bash
68
+ run: |
69
+ set -e
70
+ uv venv .venv
71
+ source .venv/bin/activate
72
+ uv pip install fastgeodesic --no-index --no-deps --find-links dist --reinstall
73
+ uv pip install "fastgeodesic[test]" --find-links dist
74
+ pytest
75
+ - name: pytest
76
+ if: ${{ !startsWith(matrix.platform.target, 'x86') && matrix.platform.target != 'ppc64' }}
77
+ uses: uraimo/run-on-arch-action@v3
78
+ with:
79
+ arch: ${{ matrix.platform.target }}
80
+ distro: ubuntu24.04
81
+ githubToken: ${{ github.token }}
82
+ install: |
83
+ apt-get update
84
+ apt-get install -y --no-install-recommends python3 python3-venv
85
+ run: |
86
+ set -e
87
+ python3 -m venv .venv
88
+ source .venv/bin/activate
89
+ pip install fastgeodesic --no-index --no-deps --find-links dist --force-reinstall
90
+ pip install "fastgeodesic[test]" --find-links dist
91
+ pytest
92
+
93
+ musllinux:
94
+ runs-on: ${{ matrix.platform.runner }}
95
+ strategy:
96
+ matrix:
97
+ platform:
98
+ - runner: ubuntu-22.04
99
+ target: x86_64
100
+ - runner: ubuntu-22.04
101
+ target: x86
102
+ - runner: ubuntu-22.04
103
+ target: aarch64
104
+ - runner: ubuntu-22.04
105
+ target: armv7
106
+ steps:
107
+ - uses: actions/checkout@v6
108
+ - uses: actions/setup-python@v6
109
+ with:
110
+ python-version: "3.9"
111
+ - name: Build wheels
112
+ uses: PyO3/maturin-action@v1
113
+ with:
114
+ target: ${{ matrix.platform.target }}
115
+ args: --release --out dist
116
+ sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
117
+ manylinux: musllinux_1_2
118
+ - name: Build free-threaded wheels
119
+ uses: PyO3/maturin-action@v1
120
+ with:
121
+ target: ${{ matrix.platform.target }}
122
+ args: --release --out dist -i python3.14t
123
+ sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
124
+ manylinux: musllinux_1_2
125
+ - name: Upload wheels
126
+ uses: actions/upload-artifact@v6
127
+ with:
128
+ name: wheels-musllinux-${{ matrix.platform.target }}
129
+ path: dist
130
+ - name: pytest
131
+ if: ${{ startsWith(matrix.platform.target, 'x86_64') }}
132
+ run: |
133
+ set -e
134
+ docker run --rm -v ${{ github.workspace }}:/io -w /io alpine:latest sh -c '
135
+ apk add py3-pip py3-virtualenv
136
+ python3 -m virtualenv .venv
137
+ source .venv/bin/activate
138
+ pip install fastgeodesic --no-index --no-deps --find-links dist --force-reinstall
139
+ pip install "fastgeodesic[test]" --find-links dist
140
+ pytest
141
+ '
142
+ - name: pytest
143
+ if: ${{ !startsWith(matrix.platform.target, 'x86') }}
144
+ uses: uraimo/run-on-arch-action@v3
145
+ with:
146
+ arch: ${{ matrix.platform.target }}
147
+ distro: alpine_latest
148
+ githubToken: ${{ github.token }}
149
+ install: |
150
+ apk add py3-virtualenv
151
+ run: |
152
+ set -e
153
+ python3 -m virtualenv .venv
154
+ source .venv/bin/activate
155
+ pip install fastgeodesic --no-index --no-deps --find-links dist --force-reinstall
156
+ pip install "fastgeodesic[test]" --find-links dist
157
+ pytest
158
+
159
+ windows:
160
+ runs-on: ${{ matrix.platform.runner }}
161
+ strategy:
162
+ matrix:
163
+ platform:
164
+ - runner: windows-latest
165
+ target: x64
166
+ python_arch: x64
167
+ - runner: windows-latest
168
+ target: x86
169
+ python_arch: x86
170
+ - runner: windows-11-arm
171
+ target: aarch64
172
+ python_arch: arm64
173
+ steps:
174
+ - uses: actions/checkout@v6
175
+ - uses: actions/setup-python@v6
176
+ with:
177
+ python-version: "3.13"
178
+ architecture: ${{ matrix.platform.python_arch }}
179
+ - name: Build wheels
180
+ uses: PyO3/maturin-action@v1
181
+ with:
182
+ target: ${{ matrix.platform.target }}
183
+ args: --release --out dist
184
+ sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
185
+ - uses: actions/setup-python@v6
186
+ with:
187
+ python-version: "3.14t"
188
+ architecture: ${{ matrix.platform.python_arch }}
189
+ - name: Build free-threaded wheels
190
+ uses: PyO3/maturin-action@v1
191
+ with:
192
+ target: ${{ matrix.platform.target }}
193
+ args: --release --out dist -i python3.14t
194
+ sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
195
+ - name: Upload wheels
196
+ uses: actions/upload-artifact@v6
197
+ with:
198
+ name: wheels-windows-${{ matrix.platform.target }}
199
+ path: dist
200
+ - uses: astral-sh/setup-uv@v7
201
+ - name: pytest
202
+ shell: bash
203
+ run: |
204
+ set -e
205
+ uv venv .venv
206
+ source .venv/Scripts/activate
207
+ uv pip install fastgeodesic --no-index --no-deps --find-links dist --reinstall
208
+ uv pip install "fastgeodesic[test]" --find-links dist
209
+ pytest
210
+
211
+ macos:
212
+ runs-on: ${{ matrix.platform.runner }}
213
+ strategy:
214
+ matrix:
215
+ platform:
216
+ - runner: macos-15-intel
217
+ target: x86_64
218
+ - runner: macos-latest
219
+ target: aarch64
220
+ steps:
221
+ - uses: actions/checkout@v6
222
+ - uses: actions/setup-python@v6
223
+ with:
224
+ python-version: "3.9"
225
+ - name: Build wheels
226
+ uses: PyO3/maturin-action@v1
227
+ with:
228
+ target: ${{ matrix.platform.target }}
229
+ args: --release --out dist
230
+ sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
231
+ - uses: actions/setup-python@v6
232
+ with:
233
+ python-version: "3.14t"
234
+ - name: Build free-threaded wheels
235
+ uses: PyO3/maturin-action@v1
236
+ with:
237
+ target: ${{ matrix.platform.target }}
238
+ args: --release --out dist -i python3.14t
239
+ sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
240
+ - name: Upload wheels
241
+ uses: actions/upload-artifact@v6
242
+ with:
243
+ name: wheels-macos-${{ matrix.platform.target }}
244
+ path: dist
245
+ - uses: astral-sh/setup-uv@v7
246
+ - name: pytest
247
+ run: |
248
+ set -e
249
+ uv venv .venv
250
+ source .venv/bin/activate
251
+ uv pip install fastgeodesic --no-index --no-deps --find-links dist --reinstall
252
+ uv pip install "fastgeodesic[test]" --find-links dist
253
+ pytest
254
+
255
+ sdist:
256
+ runs-on: ubuntu-latest
257
+ steps:
258
+ - uses: actions/checkout@v6
259
+ - name: Build sdist
260
+ uses: PyO3/maturin-action@v1
261
+ with:
262
+ command: sdist
263
+ args: --out dist
264
+ - name: Upload sdist
265
+ uses: actions/upload-artifact@v6
266
+ with:
267
+ name: wheels-sdist
268
+ path: dist
269
+
270
+ release:
271
+ name: Release
272
+ runs-on: ubuntu-latest
273
+ if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
274
+ needs: [linux, musllinux, windows, macos, sdist]
275
+ permissions:
276
+ # Use to sign the release artifacts
277
+ id-token: write
278
+ # Used to upload release artifacts
279
+ contents: write
280
+ # Used to generate artifact attestation
281
+ attestations: write
282
+ steps:
283
+ - uses: actions/download-artifact@v7
284
+ - name: Generate artifact attestation
285
+ uses: actions/attest@v4
286
+ with:
287
+ subject-path: 'wheels-*/*'
288
+ - name: Install uv
289
+ if: ${{ startsWith(github.ref, 'refs/tags/') }}
290
+ uses: astral-sh/setup-uv@v7
291
+ - name: Publish to PyPI
292
+ if: ${{ startsWith(github.ref, 'refs/tags/') }}
293
+ # Trusted Publishing: no API token is stored. Register this workflow on PyPI first.
294
+ run: uv publish --trusted-publishing always 'wheels-*/*'
@@ -0,0 +1,4 @@
1
+ target/
2
+ .venv/
3
+ __pycache__/
4
+ *.so
@@ -0,0 +1,222 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "accurate"
7
+ version = "0.3.1"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "4f209f0bc218ee6cf50db56ec0d9fe10b3cbfb6f3900d019b36c8fdb6d3bc03e"
10
+ dependencies = [
11
+ "cfg-if",
12
+ "ieee754",
13
+ "num-traits",
14
+ ]
15
+
16
+ [[package]]
17
+ name = "autocfg"
18
+ version = "1.5.1"
19
+ source = "registry+https://github.com/rust-lang/crates.io-index"
20
+ checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
21
+
22
+ [[package]]
23
+ name = "cfg-if"
24
+ version = "1.0.5"
25
+ source = "registry+https://github.com/rust-lang/crates.io-index"
26
+ checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
27
+
28
+ [[package]]
29
+ name = "fastgeodesic"
30
+ version = "0.1.0"
31
+ dependencies = [
32
+ "geographiclib-rs",
33
+ "pyo3",
34
+ ]
35
+
36
+ [[package]]
37
+ name = "geographiclib-rs"
38
+ version = "0.2.7"
39
+ source = "registry+https://github.com/rust-lang/crates.io-index"
40
+ checksum = "c5a7f08910fd98737a6eda7568e7c5e645093e073328eeef49758cfe8b0489c7"
41
+ dependencies = [
42
+ "accurate",
43
+ "libm",
44
+ ]
45
+
46
+ [[package]]
47
+ name = "heck"
48
+ version = "0.5.0"
49
+ source = "registry+https://github.com/rust-lang/crates.io-index"
50
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
51
+
52
+ [[package]]
53
+ name = "ieee754"
54
+ version = "0.2.6"
55
+ source = "registry+https://github.com/rust-lang/crates.io-index"
56
+ checksum = "9007da9cacbd3e6343da136e98b0d2df013f553d35bdec8b518f07bea768e19c"
57
+
58
+ [[package]]
59
+ name = "indoc"
60
+ version = "2.0.8"
61
+ source = "registry+https://github.com/rust-lang/crates.io-index"
62
+ checksum = "a37b2691796cffeb8a8cd305ac66e65841559f147f4e63231d0eafa4db5384d1"
63
+ dependencies = [
64
+ "rustversion",
65
+ ]
66
+
67
+ [[package]]
68
+ name = "libc"
69
+ version = "0.2.191"
70
+ source = "registry+https://github.com/rust-lang/crates.io-index"
71
+ checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
72
+
73
+ [[package]]
74
+ name = "libm"
75
+ version = "0.2.16"
76
+ source = "registry+https://github.com/rust-lang/crates.io-index"
77
+ checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"
78
+
79
+ [[package]]
80
+ name = "memoffset"
81
+ version = "0.9.1"
82
+ source = "registry+https://github.com/rust-lang/crates.io-index"
83
+ checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
84
+ dependencies = [
85
+ "autocfg",
86
+ ]
87
+
88
+ [[package]]
89
+ name = "num-traits"
90
+ version = "0.2.19"
91
+ source = "registry+https://github.com/rust-lang/crates.io-index"
92
+ checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
93
+ dependencies = [
94
+ "autocfg",
95
+ ]
96
+
97
+ [[package]]
98
+ name = "once_cell"
99
+ version = "1.21.4"
100
+ source = "registry+https://github.com/rust-lang/crates.io-index"
101
+ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
102
+
103
+ [[package]]
104
+ name = "portable-atomic"
105
+ version = "1.15.0"
106
+ source = "registry+https://github.com/rust-lang/crates.io-index"
107
+ checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
108
+
109
+ [[package]]
110
+ name = "proc-macro2"
111
+ version = "1.0.107"
112
+ source = "registry+https://github.com/rust-lang/crates.io-index"
113
+ checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
114
+ dependencies = [
115
+ "unicode-ident",
116
+ ]
117
+
118
+ [[package]]
119
+ name = "pyo3"
120
+ version = "0.25.1"
121
+ source = "registry+https://github.com/rust-lang/crates.io-index"
122
+ checksum = "8970a78afe0628a3e3430376fc5fd76b6b45c4d43360ffd6cdd40bdde72b682a"
123
+ dependencies = [
124
+ "indoc",
125
+ "libc",
126
+ "memoffset",
127
+ "once_cell",
128
+ "portable-atomic",
129
+ "pyo3-build-config",
130
+ "pyo3-ffi",
131
+ "pyo3-macros",
132
+ "unindent",
133
+ ]
134
+
135
+ [[package]]
136
+ name = "pyo3-build-config"
137
+ version = "0.25.1"
138
+ source = "registry+https://github.com/rust-lang/crates.io-index"
139
+ checksum = "458eb0c55e7ece017adeba38f2248ff3ac615e53660d7c71a238d7d2a01c7598"
140
+ dependencies = [
141
+ "once_cell",
142
+ "target-lexicon",
143
+ ]
144
+
145
+ [[package]]
146
+ name = "pyo3-ffi"
147
+ version = "0.25.1"
148
+ source = "registry+https://github.com/rust-lang/crates.io-index"
149
+ checksum = "7114fe5457c61b276ab77c5055f206295b812608083644a5c5b2640c3102565c"
150
+ dependencies = [
151
+ "libc",
152
+ "pyo3-build-config",
153
+ ]
154
+
155
+ [[package]]
156
+ name = "pyo3-macros"
157
+ version = "0.25.1"
158
+ source = "registry+https://github.com/rust-lang/crates.io-index"
159
+ checksum = "a8725c0a622b374d6cb051d11a0983786448f7785336139c3c94f5aa6bef7e50"
160
+ dependencies = [
161
+ "proc-macro2",
162
+ "pyo3-macros-backend",
163
+ "quote",
164
+ "syn",
165
+ ]
166
+
167
+ [[package]]
168
+ name = "pyo3-macros-backend"
169
+ version = "0.25.1"
170
+ source = "registry+https://github.com/rust-lang/crates.io-index"
171
+ checksum = "4109984c22491085343c05b0dbc54ddc405c3cf7b4374fc533f5c3313a572ccc"
172
+ dependencies = [
173
+ "heck",
174
+ "proc-macro2",
175
+ "pyo3-build-config",
176
+ "quote",
177
+ "syn",
178
+ ]
179
+
180
+ [[package]]
181
+ name = "quote"
182
+ version = "1.0.47"
183
+ source = "registry+https://github.com/rust-lang/crates.io-index"
184
+ checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
185
+ dependencies = [
186
+ "proc-macro2",
187
+ ]
188
+
189
+ [[package]]
190
+ name = "rustversion"
191
+ version = "1.0.23"
192
+ source = "registry+https://github.com/rust-lang/crates.io-index"
193
+ checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
194
+
195
+ [[package]]
196
+ name = "syn"
197
+ version = "2.0.119"
198
+ source = "registry+https://github.com/rust-lang/crates.io-index"
199
+ checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
200
+ dependencies = [
201
+ "proc-macro2",
202
+ "quote",
203
+ "unicode-ident",
204
+ ]
205
+
206
+ [[package]]
207
+ name = "target-lexicon"
208
+ version = "0.13.5"
209
+ source = "registry+https://github.com/rust-lang/crates.io-index"
210
+ checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
211
+
212
+ [[package]]
213
+ name = "unicode-ident"
214
+ version = "1.0.27"
215
+ source = "registry+https://github.com/rust-lang/crates.io-index"
216
+ checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
217
+
218
+ [[package]]
219
+ name = "unindent"
220
+ version = "0.2.4"
221
+ source = "registry+https://github.com/rust-lang/crates.io-index"
222
+ checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
@@ -0,0 +1,19 @@
1
+ [package]
2
+ name = "fastgeodesic"
3
+ version = "0.1.0"
4
+ edition = "2021"
5
+ license = "MIT"
6
+ readme = "README.md"
7
+
8
+ [lib]
9
+ name = "_core"
10
+ crate-type = ["cdylib"]
11
+
12
+ [dependencies]
13
+ pyo3 = { version = "0.25", features = ["extension-module", "abi3-py39"] }
14
+ geographiclib-rs = "0.2.7"
15
+
16
+ [profile.release]
17
+ opt-level = 3
18
+ lto = true
19
+ codegen-units = 1
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 cherenkov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,139 @@
1
+ Metadata-Version: 2.4
2
+ Name: fastgeodesic
3
+ Version: 0.1.0
4
+ Requires-Dist: geopy>=2.0,<3 ; extra == 'geopy'
5
+ Requires-Dist: pytest ; extra == 'test'
6
+ Requires-Dist: geographiclib ; extra == 'test'
7
+ Requires-Dist: geopy>=2.0,<3 ; extra == 'test'
8
+ Requires-Dist: numpy ; (platform_machine == 'AMD64' and extra == 'test') or (platform_machine == 'aarch64' and extra == 'test') or (platform_machine == 'arm64' and extra == 'test') or (platform_machine == 'x86_64' and extra == 'test')
9
+ Provides-Extra: geopy
10
+ Provides-Extra: test
11
+ License-File: LICENSE
12
+ Summary: Drop-in Rust replacement for geographiclib and geopy distance: same results, 18-32x faster
13
+ Keywords: geodesic,geographiclib,geopy,distance,wgs84,gps,rust
14
+ License: MIT
15
+ Requires-Python: >=3.9
16
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
17
+ Project-URL: Issues, https://github.com/cherenkov/fastgeodesic/issues
18
+ Project-URL: Repository, https://github.com/cherenkov/fastgeodesic
19
+
20
+ # fastgeodesic
21
+
22
+ Drop-in Rust replacement for [geographiclib](https://pypi.org/project/geographiclib/) and the distance functions of [geopy](https://pypi.org/project/geopy/). Same API, same results, 18–32x faster.
23
+
24
+ Replace `geopy` (or `geographiclib`) with `fastgeodesic` in the import. Nothing else changes.
25
+
26
+ ```python
27
+ # before
28
+ from geopy.distance import geodesic
29
+ # after
30
+ from fastgeodesic.distance import geodesic
31
+
32
+ geodesic((35.3606, 138.7274), (35.6812, 139.7671)).meters
33
+ ```
34
+
35
+ ## Why
36
+
37
+ geographiclib is the standard library for accurate distances on the WGS84 ellipsoid, and geopy uses it under the hood. It is written in pure Python, so one distance takes about 40 µs. Loops over GPS logs, AIS tracks or all pairs of stations call it hundreds of thousands of times, which turns into minutes.
38
+
39
+ The usual advice is to switch to `pyproj.Geod` and rewrite the code to work on arrays. fastgeodesic is for when you would rather not rewrite: it runs the same algorithm (Karney 2013, via [geographiclib-rs](https://github.com/georust/geographiclib-rs)) in Rust and keeps the call-by-call API.
40
+
41
+ ## Speed
42
+
43
+ Apple M1 Pro, Python 3.12, median of repeated runs.
44
+
45
+ | Workload | geographiclib / geopy | fastgeodesic | Speedup |
46
+ |---|---|---|---|
47
+ | `Geodesic.WGS84.Inverse`, 50,000 random pairs | 2,107 ms | 65 ms | 32x |
48
+ | `fastgeodesic.inverse_many`, same pairs | 2,107 ms | 33 ms | 64x |
49
+ | `geopy.distance.geodesic`, 20,000 random pairs | 1,202 ms | 39 ms | 31x |
50
+ | Total length of a 100,000-point GPS log with `geopy.distance.geodesic` | 3,566 ms | 159 ms | 22x |
51
+ | Same GPS log with `numpy.float64` coordinates (pandas rows) | 3,622 ms | 203 ms | 18x |
52
+
53
+ Short distances such as consecutive GPS points converge quickly even in pure Python, so the speedup there is smaller than for random pairs.
54
+
55
+ ## Accuracy
56
+
57
+ Results match geographiclib to the last few bits. On 100,000 random pairs, 59% of `Inverse` results are bit-for-bit identical, and the largest difference is 7.5e-9 m in distance and 7.4e-13 degrees in azimuth. The test suite compares every output key against geographiclib, including poles, the antimeridian, near-antipodal points, `LONG_UNROLL` and a non-WGS84 ellipsoid. `fastgeodesic.distance` is tested against `geopy.distance` with floats, ints, lists, strings, `Point` objects, altitudes, `numpy.float64`, several points, other ellipsoids and `destination()`. Invalid input raises the same exception with the same message.
58
+
59
+ ## Usage
60
+
61
+ The rule is always the same: replace the package name in the import.
62
+
63
+ | Before | After |
64
+ |---|---|
65
+ | `from geopy.distance import geodesic` | `from fastgeodesic.distance import geodesic` |
66
+ | `from geopy import distance` | `from fastgeodesic import distance` |
67
+ | `from geographiclib.geodesic import Geodesic` | `from fastgeodesic.geodesic import Geodesic` |
68
+
69
+ Only the files where you change the import are affected. geopy and geographiclib themselves are not modified, so other code in the same program keeps using them.
70
+
71
+ `fastgeodesic.distance.geodesic` is a subclass of `geopy.distance.geodesic`, so `.km`, `.miles`, `.destination()`, arithmetic, comparisons, `ellipsoid=` and `isinstance` checks work as before. The other names in `fastgeodesic.distance` (`great_circle`, `Distance`, `ELLIPSOIDS`, ...) are geopy's own objects.
72
+
73
+ `fastgeodesic.geodesic.Geodesic` has the same API as `geographiclib.geodesic.Geodesic`:
74
+
75
+ ```python
76
+ from fastgeodesic.geodesic import Geodesic
77
+
78
+ r = Geodesic.WGS84.Inverse(35.3606, 138.7274, 35.6812, 139.7671)
79
+ r["s12"], r["azi1"], r["azi2"]
80
+
81
+ Geodesic.WGS84.Direct(35.3606, 138.7274, 45.0, 10_000, Geodesic.LATITUDE | Geodesic.LONGITUDE)
82
+ Geodesic(6377397.155, 1 / 299.1528128) # any ellipsoid
83
+ ```
84
+
85
+ For many pairs at once:
86
+
87
+ ```python
88
+ import fastgeodesic
89
+ fastgeodesic.inverse_many(lat1, lon1, lat2, lon2) # list of distances in meters, WGS84
90
+ ```
91
+
92
+ ### When you cannot change the import
93
+
94
+ If geopy is called inside a library you do not control, `patch()` makes geographiclib and geopy compute with fastgeodesic for the whole program:
95
+
96
+ ```python
97
+ import fastgeodesic
98
+ fastgeodesic.patch() # replaces Geodesic in geographiclib.geodesic and geopy.distance
99
+ ...
100
+ fastgeodesic.unpatch() # restores the originals
101
+ ```
102
+
103
+ It replaces exactly one name, `Geodesic`, in those two modules. Call it before other modules copy the name with `from geographiclib.geodesic import Geodesic`. The speedup is smaller than changing the import (9x instead of 22x on GPS logs) because geopy's own Python code still runs.
104
+
105
+ ## Supported API
106
+
107
+ | geographiclib | Status |
108
+ |---|---|
109
+ | `Geodesic(a, f)`, `Geodesic.WGS84`, `a`, `f`, all outmask constants | Supported |
110
+ | `Inverse(lat1, lon1, lat2, lon2, outmask)` | Supported |
111
+ | `Direct(lat1, lon1, azi1, s12, outmask)` | Supported |
112
+ | `ArcDirect`, `Line`, `InverseLine`, `DirectLine`, `Polygon` | Not yet |
113
+
114
+ | geopy.distance | Status |
115
+ |---|---|
116
+ | `geodesic`, `distance`, `GeodesicDistance`, including `ellipsoid=` | Supported, distances computed with fastgeodesic |
117
+ | `geodesic(...).destination()` | Supported, computed by geopy itself |
118
+ | `great_circle`, `Distance`, `ELLIPSOIDS` and the rest | geopy's own objects, passed through |
119
+
120
+
121
+ ## Install
122
+
123
+ ```sh
124
+ pip install fastgeodesic
125
+ ```
126
+
127
+ Prebuilt wheels for Linux, macOS and Windows on x86_64 and ARM, Python 3.9 and later. `fastgeodesic.distance` needs geopy 2.x, which you already have if you are replacing geopy imports; `pip install "fastgeodesic[geopy]"` installs it too.
128
+
129
+ To build from source you need a Rust toolchain:
130
+
131
+ ```sh
132
+ pip install maturin
133
+ maturin develop --release
134
+ ```
135
+
136
+ ## License
137
+
138
+ MIT. Uses [geographiclib-rs](https://github.com/georust/geographiclib-rs) (MIT), a port of Charles Karney's [GeographicLib](https://geographiclib.sourceforge.io/).
139
+