Skip to main content

fast-geodist

PyPI CI Release Code Style

An implementation of the Haversine formula for calculating Great Circle distance using Rust and PyO3.

This package was started as an experiment for learning how to implement functions in Rust and wrap them for use in python. The Haversine Formula is implemented following georust, with an array-wise implementation written using ndarray::parallel. It is wrapped for python using Maturin and integrates rust-numpy for array operations.

Installation

pip install fast-geodist

Quick start

The package provides two main entry points:

import numpy as np
from fast_geodist import haversine

# input either a tuple of (lat/lon, lat/lon)
result = haversine((1, 1, 0, 0))

# or a numpy array of coordinates pairs
# useful if lots of distances need to be calculated
# will be computed in parallel
result = haversine(np.array([(1, 1, 0, 0), (2, 2, 0, 0)]))

Benchmarks

The results of benchmarking show the rust implementation is 14x faster than the python implementation. This benchmark computes distances on an array containing 1,000,000 pairs of coordinates (see bench.py):

--------------------------------------------- benchmark: 2 tests ---------------------------------------------
Name (time in ms)              Min                   Max                  Mean                Median
--------------------------------------------------------------------------------------------------------------
test_benchmark_fast       164.0635 (1.0)        171.7663 (1.0)        168.0218 (1.0)        168.4129 (1.0)
test_benchmark_slow     2,335.4281 (14.23)    2,439.7850 (14.20)    2,395.6077 (14.26)    2,406.6356 (14.29)
--------------------------------------------------------------------------------------------------------------

Computed on an Intel i7-1165G7.

Development

Prequisites:

After cloning the repository, the Makefile includes helpful commands for setting up a development environment, linting, formatting, testing, and benchmarking. Get started as follows:

# setup a new virtual environment
python -m venv .venv
source .venv/bin/activate

# install the development dependencies
make install

# check other available commands
make help

Tooling:

References

As well as the excellent PyO3 documentation, the following posts helped with creation of this package:

Metadata

Release files for fast-geodist 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fast-geodist 0.4.0
File Size Uploaded Provenance Actions
fast_geodist-0.4.0.tar.gz 11.4 kB Without provenance Details for fast_geodist-0.4.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for fast-geodist 0.4.0
File Actions
fast_geodist-0.4.0-cp37-abi3-win_amd64.whl CPython 3.7 abi3 Windows x86-64 Details for fast_geodist-0.4.0-cp37-abi3-win_amd64.whl
fast_geodist-0.4.0-cp37-abi3-win32.whl CPython 3.7 abi3 Windows x86-32 Details for fast_geodist-0.4.0-cp37-abi3-win32.whl
fast_geodist-0.4.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.7 abi3 Linux glibc 2.17+ x86-64 Details for fast_geodist-0.4.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
fast_geodist-0.4.0-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl CPython 3.7 abi3 Linux glibc 2.17+ x86-32 Details for fast_geodist-0.4.0-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
fast_geodist-0.4.0-cp37-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl CPython 3.7 abi3 macOS 11.0+ ARM64, macOS 10.9+ universal2 (ARM64, x86-64), macOS 10.9+ x86-64 Details for fast_geodist-0.4.0-cp37-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
fast_geodist-0.4.0-cp37-abi3-macosx_10_7_x86_64.whl CPython 3.7 abi3 macOS 10.7+ x86-64 Details for fast_geodist-0.4.0-cp37-abi3-macosx_10_7_x86_64.whl

Total release size: 3.5 MB

Release files / fast_geodist-0.4.0.tar.gz

Download URL fast_geodist-0.4.0.tar.gz
Size 11.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ef291fd2119be372b198f106b820af98858481319f5192fbe012f4430b51ccf0
BLAKE2b-256 checksum
How to use checksums
1366b9cd4cf7198e85e0e34beafefa61ba932532afce82c34b944ff46a439c91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.13.5

Release files / fast_geodist-0.4.0-cp37-abi3-win_amd64.whl

Download URL fast_geodist-0.4.0-cp37-abi3-win_amd64.whl
Size 179.5 kB
Tags CPython 3.7 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
4eb25ab9b1c73b89dda6297de76e558c69b97733a4f0c901ea0fb0d3294dc6a0
BLAKE2b-256 checksum
How to use checksums
e4b6cc7c935a9d52198911ce001d124448e0cd43fa3b1dc143de45138f5b2d5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.13.5

Release files / fast_geodist-0.4.0-cp37-abi3-win32.whl

Download URL fast_geodist-0.4.0-cp37-abi3-win32.whl
Size 171.1 kB
Tags CPython 3.7 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
22015b0999ac1a20f4a5730ccb453c0f846c69a7201a1a68e43dfefb9914f606
BLAKE2b-256 checksum
How to use checksums
d87519b18623ded8f73b0726a97ce51573038aba4593660903350dee522f2231
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.13.5

Release files / fast_geodist-0.4.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL fast_geodist-0.4.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.1 MB
Tags CPython 3.7 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
c963823ed66324b9aab55016b5d502573777738137e5108a098d8efdb4b49136
BLAKE2b-256 checksum
How to use checksums
e8c04ba5983c10ef3aa49a2f93aed352dcdbd8adba5e232ecc24b5de6a6e6958
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.13.5

Release files / fast_geodist-0.4.0-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl

Download URL fast_geodist-0.4.0-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Size 1.1 MB
Tags CPython 3.7 Linux glibc 2.17+ x86-32 abi3
SHA-256 checksum
How to use checksums
9f7778a7069133a038464cda56c9dc6978dd9a4a2ee3e76e4a29539d5d804f47
BLAKE2b-256 checksum
How to use checksums
284352049780560b4fa2b0091704500ebcdd754c8203f37a9ceab107b74c18ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.13.5

Release files / fast_geodist-0.4.0-cp37-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl

Download URL fast_geodist-0.4.0-cp37-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Size 597.1 kB
Tags CPython 3.7 abi3 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
312d8576c1910bf8b92b6bca0e6a9b94e5e46e67f6168022c875e4ea2bf18ad8
BLAKE2b-256 checksum
How to use checksums
adea14dbfcd3c8c33177bf1a29e2a3d8ec15ea04bec5ea704b0b9561cc08b370
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.13.5

Release files / fast_geodist-0.4.0-cp37-abi3-macosx_10_7_x86_64.whl

Download URL fast_geodist-0.4.0-cp37-abi3-macosx_10_7_x86_64.whl
Size 305.4 kB
Tags CPython 3.7 abi3 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
35d42fed6371e00a46555b56016b30eeffc9329c7074b7351baaa8308516f273
BLAKE2b-256 checksum
How to use checksums
ee3ac7e1b014a35375b95238110fe63c2a8829db7eb988c40a4e442056906f11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.13.5

Security for fast-geodist 0.4.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.4.0 This release

7 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page