Skip to main content

An experimental Python library for parsing GPX files fast.

Project description

fastgpx

An experimental Python library for parsing GPX files fast.

# Get the total length of the tracks in a GPX file:
import fastgpx

gpx = fastgpx.parse("example.gpx")
print(f'{gpx.length_2d()} m')
# Iterate over GPX file:
import fastgpx

gpx = fastgpx.parse("example.gpx")
for track in gpx.tracks:
    print(f'Track: {track.name}')
    print(f'Distance: {track.length_2d()} m')
    if not track.time_bounds.is_empty():
      print(f'Time: {track.time_bounds().start_time} - {track.time_bounds().end_time}')
    for segment in track.segments:
        print(f'Segment: {segment.name}')
        for point in segment.points:
            print(f'Point: {point.latitude}, {point.longitude}')

Documentation

Requirements

  • Python 3.11+ (Tested with 3.11, 3.12)
  • C++23 Compiler

Windows

  • Tested with MSVC 17.12.4+ and Clang-cl 19+.

Linux (Tested on Ubuntu)

  • C++23 compatible runtime (GCC libstdc++ 14+ or Clang libc++ 18.1+)

GPX/XML Performance (Background)

gpxpy appear to be the most popular GPX library for Python.

gpxpy docs says that it uses lxml is available because it is faster than "minidom" (etree). When benchmarking that seemed not to be the case. It appear that the stdlib XML library has gotten much better since gpxpy was created.

Reference: Open ticket on making etree default: https://github.com/tkrajina/gpxpy/issues/248

Benchmarks

Test machine:

  • AMD Ryzen 7 5800 8-Core, 3.80 GHz
  • 32 GB memory
  • m2 SSD storage

gpxpy benchmarks

Comparing getting the distance of a GPX file using gpxpy vs manually extracting the data using xml_etree, computing distance between points using gpxpy distance functions.

gpxpy without lxml

Running benchmark with 3 iterations...
gpxpy 5463041.784135511 meters
gpxpy 5463041.784135511 meters
gpxpy 5463041.784135511 meters
gpxpy: 11.497863 seconds (Average: 3.832621 seconds)

gpxpy with lxml

Running benchmark with 3 iterations...
gpxpy 5463041.784135511 meters
gpxpy 5463041.784135511 meters
gpxpy 5463041.784135511 meters
gpxpy: 37.803625 seconds (Average: 12.601208 seconds)

xml_etree data extraction

Running benchmark with 3 iterations...
xml_etree 5463043.740615641 meters
xml_etree 5463043.740615641 meters
xml_etree 5463043.740615641 meters
xml_etree: 2.333200 seconds (Average: 0.777733 seconds)

Even with gpxpy using etree to parse the XML it is paster to parse it directly with etree and use gpxpy.geo distance functions to compute the distance of a GPX file. Unclear what the extra overhead is, possibly the cost of extraction additional data. (Some minor difference in how the total distance is computed in this example. Using different options for computing the distance.)

C++ benchmarks

Since XML parsing itself appear to have a significant impact on performance some popular C++ XML libraries was tested:

tinyxml2

Total Length: 5456930.710560566
Elapsed time: 0.4980144 seconds

pugixml

Total Length: 5456930.710560566
Elapsed time: 0.1890089 seconds

C++ vs Python implementations

Running 5 benchmarks with 3 iterations...

Running gpxpy ...
gpxpy: 50.182288 seconds (Average: 16.727429 seconds)

Running xml_etree ...
xml_etree: 8.269050 seconds (Average: 2.756350 seconds)

Running lxml ...
lxml: 8.479702 seconds (Average: 2.826567 seconds)

Running tinyxml (C++) ...
tinyxml (C++): 2.699880 seconds (Average: 0.899960 seconds)

Running pugixml (C++) ...
pugixml (C++): 0.381095 seconds (Average: 0.127032 seconds)

For computing the length of a GPX file, pugixml in a Python C extension was ~140 times faster than using gpxpy.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastgpx-0.5.0.tar.gz (83.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

fastgpx-0.5.0-cp312-abi3-win_arm64.whl (689.6 kB view details)

Uploaded CPython 3.12+Windows ARM64

fastgpx-0.5.0-cp312-abi3-win_amd64.whl (766.5 kB view details)

Uploaded CPython 3.12+Windows x86-64

fastgpx-0.5.0-cp312-abi3-win32.whl (666.7 kB view details)

Uploaded CPython 3.12+Windows x86

fastgpx-0.5.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

fastgpx-0.5.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (3.9 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

File details

Details for the file fastgpx-0.5.0.tar.gz.

File metadata

  • Download URL: fastgpx-0.5.0.tar.gz
  • Upload date:
  • Size: 83.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fastgpx-0.5.0.tar.gz
Algorithm Hash digest
SHA256 eab082a3e418cc9a711e05ec60ddac73615f68001f4c6fa92d0b68d3b6368b60
MD5 2d21659493173815ef3103a5470ead74
BLAKE2b-256 69a3aeff05aa3bddd9c8d12cd0e8c9e5a0236409a582b3fe205ed37682deec10

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastgpx-0.5.0.tar.gz:

Publisher: wheels.yml on thomthom/fastgpx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastgpx-0.5.0-cp312-abi3-win_arm64.whl.

File metadata

  • Download URL: fastgpx-0.5.0-cp312-abi3-win_arm64.whl
  • Upload date:
  • Size: 689.6 kB
  • Tags: CPython 3.12+, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fastgpx-0.5.0-cp312-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 bb206bd6a990ae55285ecd556281a17fca99f9dfdb0be1c41aa22f892eaa18a5
MD5 a1a02b9c762a827af42c2d81b4858fac
BLAKE2b-256 73a3d5d3336cc4d391787409d92cd0ccc2c6d2ac6f496646e4bb3e5eba03f059

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastgpx-0.5.0-cp312-abi3-win_arm64.whl:

Publisher: wheels.yml on thomthom/fastgpx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastgpx-0.5.0-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: fastgpx-0.5.0-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 766.5 kB
  • Tags: CPython 3.12+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fastgpx-0.5.0-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 35a2df33e8662e10b3cddb3ec7d4156e28bf95bcf166ab2ea2457f9014723942
MD5 3cd0b6a64edf9cb76a3b4c6eb2dc37f4
BLAKE2b-256 0ca4c35c6819e76ad19e76990e5a274633365ddc8c672f0e7ea90af3268e9456

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastgpx-0.5.0-cp312-abi3-win_amd64.whl:

Publisher: wheels.yml on thomthom/fastgpx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastgpx-0.5.0-cp312-abi3-win32.whl.

File metadata

  • Download URL: fastgpx-0.5.0-cp312-abi3-win32.whl
  • Upload date:
  • Size: 666.7 kB
  • Tags: CPython 3.12+, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fastgpx-0.5.0-cp312-abi3-win32.whl
Algorithm Hash digest
SHA256 293d0cb6c92d6118e09d44a636ef6df99f940a5a58a94c7bdda83406545aade4
MD5 12834b6c1ed01a1542d1bfcec350e89a
BLAKE2b-256 c99e8f4b38436cf1226ddc6296f3778675d0ed1cf2cdb69cb0849196adcdc5b2

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastgpx-0.5.0-cp312-abi3-win32.whl:

Publisher: wheels.yml on thomthom/fastgpx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastgpx-0.5.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fastgpx-0.5.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a54a45556313a880c8c21bbb43a643b1600ddedaf9c75091c452da3a5cf6ae1b
MD5 c730e646bb14e6e2f8c69b77aed3fbe9
BLAKE2b-256 87fc389551a565c4bb3e0bbd3a4f630e2c7b1ef2f7b4ccc74193a46fb43778fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastgpx-0.5.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on thomthom/fastgpx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastgpx-0.5.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for fastgpx-0.5.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b92115607f1bcd53963979ca086154d98624960b15e49f2ecfd2f53d3560e698
MD5 ccdde2c86f14f9eec799007a7d3e2fde
BLAKE2b-256 81bcdaf3c1590461d12d6a138aa36eaeb2c92eecfa92966c8a6d273b190e553b

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastgpx-0.5.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl:

Publisher: wheels.yml on thomthom/fastgpx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page