Mojo-native, minimal Shapely-like geometry library and algorithms.
- Mojo toolchain available on your PATH (
mojo) - Python 3.13+
uv
Create / sync the virtualenv with dependencies:
uv syncuv run mojo run -I . tests/run_tests.mojoRun both the Mojo and Python benchmarks, write the results to JSON, and print a per-benchmark speedup table:
uv run python bench/compare_benchmarks.pyThis writes:
bench/results/mojo_results.jsonbench/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
This example:
- creates a couple of
LineStrings - buffers them using Mojo Shapely (
shapely.constructive.buffer) - plots the input lines + buffer result using
matplotlibvia Mojo Python-interop - writes the image to
outputs/line_buffer.png
uv run mojo run -I . examples/plot_line_buffer.mojoThe output directory is created automatically.
Line buffer cap/join style comparison (generated by examples/plot_line_buffer.mojo):
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):
Regenerate:
uv run mojo run -I . examples/plot_polygon_buffer_with_holes.mojoTic-tac-toe board linework buffered + unioned into a single footprint (prints area() and length() and saves a plot):
Regenerate:
uv run mojo run -I . examples/plot_tictactoe_buffer_metrics.mojoBoolean operations (intersection / union / difference / symmetric difference) between two polygons:
Regenerate:
uv run mojo run -I . examples/plot_boolean_operations.mojoSTRtree spatial index example (predicate query + nearest / kNN):
Regenerate:
uv run mojo run -I . examples/plot_strtree_queries.mojoshapely/- 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)




