Skip to main content

cstar – A Fast C++ Pathfinding Wrapper for Python

cstar provides a simple Python interface to high-performance C++ implementations of A*, WA*, Focal Search, and MHA*. It supports fast 2D/3D grid pathfinding with diagonal movement.


Features

  • Core A*, WA*, Focal Search, and MHA* implementations in C++ for speed
  • Clean Python API with 2D and 3D wrappers
  • Supports 8-direction (2D) and 26-direction (3D) movement
  • Works with 2D and 3D NumPy arrays
  • Benchmark script included in /benchmarks

Installation

Basic:

uv sync

Dev:

uv sync --extra dev

Usage

import numpy as np
from cstar.pathfinding import (
	run_astar_2D,
	run_wastar_2D,
	run_astar_3D,
	run_wastar_3D,
	run_mhastar_2D,
	run_mhastar_3D,
)

grid = np.ones((10, 10), dtype=bool)
path, cost, expansions, expanded = run_astar_2D(grid, 0, 0, 9, 9)

h2d = np.zeros((10, 10), dtype=float)
path_h, cost_h, expansions_h, expanded_h = run_wastar_2D(
	grid, 0, 0, 9, 9, w=1.2
)

path_mha, cost_mha, expansions_mha, expanded_mha = run_mhastar_2D(
	grid, h2d, 0, 0, 9, 9, w1=1.0, w2=1.0
)

print(path)
print(cost)
print(expansions)
print(expanded)

grid3d = np.ones((10, 10, 5), dtype=bool)
path3d, cost3d, expansions3d, expanded3d = run_astar_3D(grid3d, 0, 0, 0, 9, 9, 4)

h3d = np.zeros((10, 10, 5), dtype=float)
path3d_h, cost3d_h, expansions3d_h, expanded3d_h = run_astar_3D_heuristic_grid(
	grid3d, 0, 0, 0, 9, 9, 4, heuristic_grid=h3d, w=1.2
)

path3d_mha, cost3d_mha, expansions3d_mha, expanded3d_mha = run_mhastar_3D(
	grid3d, h3d, 0, 0, 0, 9, 9, 4, w1=1.0, w2=1.0
)

API: pathfinding wrappers

Parameters

  • 2D wrappers:
    • run_astar_2D
    • run_wastar_2D
    • run_focal_search_2D
    • run_mhastar_2D
  • 3D wrappers:
    • run_astar_3D
    • run_wastar_3D
    • run_focal_search_3D
    • run_mhastar_3D

Common parameters

  • grid: 2D/3D boolean NumPy array with True = walkable, False = obstacle (autoconverted to bool if necessary and possible)
  • x_start, y_start (, z_start): start coordinates
  • x_target, y_target (, z_target): target coordinates

Returns

  • path: NumPy array [N, 2] or [N, 3] of path waypoints
  • cost: float total path cost
  • expansions: int number of nodes expanded during the search
  • expanded: boolean grid matching input shape with expanded nodes marked True

Edge behavior:

  • The default assumes non uniform step costs (octile distance based), 2D functions have an optional parameter for uniform step costs
  • The model can always move diagonal if the diagonal cell is free, even if all other neighboring cells of the current node and diagonal node are blocked. This is mostly standard, can however be undesired for some real world applications.

Benchmarks

A benchmark script is available in the /benchmarks directory, showing performance comparisons with the python based pathfinding2D library and the C++ based pyastar library.

Metadata

Release files for cstar-pathfinding 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cstar-pathfinding 0.1.0
File Size Uploaded Provenance Actions
cstar_pathfinding-0.1.0.tar.gz 25.7 kB Without provenance Details for cstar_pathfinding-0.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for cstar-pathfinding 0.1.0
File Actions
cstar_pathfinding-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details for cstar_pathfinding-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
cstar_pathfinding-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details for cstar_pathfinding-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
cstar_pathfinding-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details for cstar_pathfinding-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
cstar_pathfinding-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details for cstar_pathfinding-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Total release size: 1.7 MB

Release files / cstar_pathfinding-0.1.0.tar.gz

Download URL cstar_pathfinding-0.1.0.tar.gz
Size 25.7 kB
Tags Source
SHA-256 checksum
How to use checksums
077ff1d50182cc9dd271a79ed7ee4da3cb7d183756106e80cc11d32211f11ebc
BLAKE2b-256 checksum
How to use checksums
771fe4881512ce0abad8e02898c42d8c8f79ebe25768ce881715db72c3db85c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.13

Release files / cstar_pathfinding-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL cstar_pathfinding-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 423.9 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
56ef4961affde68183fdb7f7e34309f0b5236e86478f1e75dcb3a35750d08106
BLAKE2b-256 checksum
How to use checksums
ca78f8c37703fa2b3ef943d7d90799e00f62710de0dad3b2a249169353034c10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.13

Release files / cstar_pathfinding-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL cstar_pathfinding-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 420.1 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
08b5df32e2da93d20d4f8a3d9c9440de9d8ba4321f8d0daa884aed01da0fa1e3
BLAKE2b-256 checksum
How to use checksums
52c2c2a1e02c3829083163ca0c181de42c163091757b60173b917613f9bd4802
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.13

Release files / cstar_pathfinding-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL cstar_pathfinding-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 417.0 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
2d36a2c5587a7ee8eb110a30eb26ec6d126efdfb783019be7cbbe513544da514
BLAKE2b-256 checksum
How to use checksums
a7b0d0bf2971b0f8943a9ad51a1ac531e8da8965cd5e21b3b60d6bc12911ac04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.13

Release files / cstar_pathfinding-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL cstar_pathfinding-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 417.7 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
bfbad8f5e4bab1d163b07910b35b16b0f48b435aa4dd8cd7166f58288e8b8246
BLAKE2b-256 checksum
How to use checksums
e84c284a0073addabe5fcb1965e7a17d0f120dda8386379d54934721ba417fc4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.13

Security for cstar-pathfinding 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

5 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page