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.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
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
matplotlibvia 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):
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.mojo
Tic-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.mojo
Boolean operations (intersection / union / difference / symmetric difference) between two polygons:
Regenerate:
uv run mojo run -I . examples/plot_boolean_operations.mojo
STRtree spatial index example (predicate query + nearest / kNN):
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)
Metadata
Release files for shapely-mojo 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| shapely_mojo-0.1.0.tar.gz | 43.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| shapely_mojo-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 92.5 kB
Release files / shapely_mojo-0.1.0.tar.gz
| Download URL | shapely_mojo-0.1.0.tar.gz |
|---|---|
| Size | 43.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6ba8bdef7ff0bbfcf0ae5dcd0e47a5a86d25cddb34141f89e57f3d8a9e26c139
|
|
BLAKE2b-256 checksum How to use checksums |
248282a2539c10894b14e0b4d6e7b2a268b0ecf8a59543bfed5f43650f7fbff9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / shapely_mojo-0.1.0-py3-none-any.whl
| Download URL | shapely_mojo-0.1.0-py3-none-any.whl |
|---|---|
| Size | 49.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
83f766523289c9146eef08e2c99ed84018a52374ce3bc7d3f2633f2afb21d771
|
|
BLAKE2b-256 checksum How to use checksums |
84da9125464af4983bfc7d8d7acb00b204a5cb64a687db72f64658f8cf186893
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|