Skip to main content

shapely-mojo

Mojo-native, minimal Shapely-like geometry library and algorithms.

Requirements

  • Mojo toolchain available on your PATH (mojo)
  • Python 3.13+
  • uv

Setup

Create / sync the virtualenv with dependencies:

uv sync

Run the Mojo tests

uv run mojo run -I . tests/run_tests.mojo

Run + compare benchmarks

Run both the Mojo and Python benchmarks, write the results to JSON, and print a per-benchmark speedup table:

uv run python bench/compare_benchmarks.py

This writes:

  • bench/results/mojo_results.json
  • bench/results/python_results.json

The printed speedup(py/mojo) value is python_seconds / mojo_seconds:

  • values > 1.0 mean Mojo is faster
  • values < 1.0 mean Python Shapely is faster

Run the buffering + matplotlib example

This example:

  • creates a couple of LineStrings
  • buffers them using Mojo Shapely (shapely.constructive.buffer)
  • plots the input lines + buffer result using matplotlib via Mojo Python-interop
  • writes the image to outputs/line_buffer.png
uv run mojo run -I . examples/plot_line_buffer.mojo

The output directory is created automatically.

Images

Line buffer cap/join style comparison (generated by examples/plot_line_buffer.mojo):

Line buffer styles

Polygon buffering with holes (shows buffer for join_style = round/bevel/mitre at distances d=0.6 and d=0.9, including how interior holes shrink/round under each join style):

Polygon buffer with holes

Regenerate:

uv run mojo run -I . examples/plot_polygon_buffer_with_holes.mojo

Tic-tac-toe board linework buffered + unioned into a single footprint (prints area() and length() and saves a plot):

Tic-tac-toe buffer

Regenerate:

uv run mojo run -I . examples/plot_tictactoe_buffer_metrics.mojo

Boolean operations (intersection / union / difference / symmetric difference) between two polygons:

Boolean operations

Regenerate:

uv run mojo run -I . examples/plot_boolean_operations.mojo

STRtree spatial index example (predicate query + nearest / kNN):

STRtree queries

Regenerate:

uv run mojo run -I . examples/plot_strtree_queries.mojo

Project layout

  • shapely/
    • Mojo implementation of geometry types and operations
  • tests/run_tests.mojo
    • Small Mojo test runner
  • examples/
    • Runnable examples (Mojo)
  • outputs/
    • Generated images/artifacts (not tracked)

Download files

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

Source Distribution

shapely_mojo-0.1.0.tar.gz (43.1 kB view details)

Uploaded Source

Built Distribution

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

shapely_mojo-0.1.0-py3-none-any.whl (49.4 kB view details)

Uploaded Python 3

File details

Details for the file shapely_mojo-0.1.0.tar.gz.

File metadata

  • Download URL: shapely_mojo-0.1.0.tar.gz
  • Upload date:
  • Size: 43.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"25.04","id":"plucky","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for shapely_mojo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6ba8bdef7ff0bbfcf0ae5dcd0e47a5a86d25cddb34141f89e57f3d8a9e26c139
MD5 7d659d892537ef22ffce1b27535db986
BLAKE2b-256 248282a2539c10894b14e0b4d6e7b2a268b0ecf8a59543bfed5f43650f7fbff9

See more details on using hashes here.

File details

Details for the file shapely_mojo-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: shapely_mojo-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 49.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"25.04","id":"plucky","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for shapely_mojo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 83f766523289c9146eef08e2c99ed84018a52374ce3bc7d3f2633f2afb21d771
MD5 400bb61dffff5c43793b16bc9db130c8
BLAKE2b-256 84da9125464af4983bfc7d8d7acb00b204a5cb64a687db72f64658f8cf186893

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

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