PyGeoHash v3.0.0: Faster, Freer, and More Pythonic

Remember that Python geohashing library I mentioned a couple days ago? Well, I’ve got some exciting news to share: PyGeoHash v3.0.0 has officially landed! This isn’t just any incremental update—it’s a complete overhaul that addresses some long-standing issues while dramatically improving performance.

The Big Changes

If you’ve been following along with my recent post about using Cursor for library maintenance, you’ll know that PyGeoHash was one of the libraries I’ve been working to revitalize. Version 3.0.0 represents the culmination of that effort, with three major improvements:

  1. Complete Rewrite in Pure CPython: The core logic has been rewritten from scratch, eliminating the dependency on the original geohash.py implementation.

  2. MIT License: The library is now available under the more permissive MIT license, making it easier to use in commercial and proprietary projects.

  3. Dramatic Performance Improvements: The new implementation is significantly faster—we’re talking orders of magnitude in some cases.

Let’s dive into each of these changes and what they mean for users.

Why Rewrite the Core Logic?

When I first created PyGeoHash back in 2015, it was essentially a Python 3 compatible fork of Leonard Norrgård’s original geohash module. While this approach got the library up and running quickly, it came with two significant drawbacks:

  1. The original implementation was GPL-3.0 licensed, which limited how PyGeoHash could be used in commercial settings.

  2. The performance was… let’s just say “not optimal” for high-volume applications.

For years, we worked around these limitations by adding Numba-accelerated variants of the core functions. This helped with performance but added dependencies and complexity to what should be a simple, lightweight library.

With v3.0.0, I’ve completely rewritten the core logic in pure CPython. This means:

  • No more GPL-licensed code
  • No more Numba or NumPy dependencies
  • Cleaner, more maintainable codebase
  • Significantly better performance

The Performance Story

Let’s talk numbers. The benchmarks tell a compelling story:

Functionv2.1.0 (μs)v3.0.0 (μs)Improvement
encode43.961.11~39x faster
decode23.514.68~5x faster
approximate_distance1.241.35Comparable
haversine_distance24.985.44~4.6x faster

The most dramatic improvement is in the encode function, which is now nearly 40 times faster than before. Even more impressive is that these improvements come without any external dependencies—it’s all standard library Python.

To put this in perspective: if you were encoding a million coordinates in a high-throughput application, the old version would take about 44 seconds. The new version? Just over 1 second.

Why MIT License Matters

Switching from GPL-3.0 to MIT is a big deal for many users. While I appreciate the principles behind GPL, I’ve come to realize that a more permissive license better serves the community by:

  1. Removing Barriers to Adoption: Companies often avoid GPL-licensed code due to concerns about the “viral” nature of the license. Whether this actually matters or not in an application, many companies prefer to avoid the risk outright and ban GPL dependencies.

  2. Simplifying Compliance: The MIT license is straightforward and easy to comply with.

  3. Encouraging Integration: It allows PyGeoHash to be easily incorporated into other libraries and applications without licensing concerns.

This change was only possible because of the complete rewrite. Since all the code is now original, the copyright holders of v3.0.0 and beyond (just me) can license it however we choose.

Upgrading to v3.0.0

For most users, upgrading should be straightforward:

pip install --upgrade pygeohash

The API remains largely compatible with previous versions, so your existing code should continue to work. However, if you were explicitly using the Numba-accelerated functions (e.g., numba_encode), you’ll need to switch to the standard functions, which are now just as fast or faster.

Try It Out!

If you work with geospatial data in Python, I encourage you to give PyGeoHash v3.0.0 a try. It’s faster, more flexible, and easier to integrate than ever before.

# Basic installation
pip install pygeohash

# With visualization support
pip install pygeohash[viz]

Check out the GitHub repository for more details, examples, and documentation.

Acknowledgments

While this release represents a complete rewrite, I want to acknowledge Leonard Norrgård’s original geohash module, which provided the foundation for the initial versions of PyGeoHash. Open source is built on the shoulders of those who came before, and I’m grateful for his work.

I’d also like to thank the users who have reported issues, suggested features, and contributed to the project over the years. Your feedback has been invaluable in shaping this release.

Are you using PyGeoHash in your projects? I’d love to hear about your use cases and experiences in the comments or on social media.