Compare commits

...

2 commits

2 changed files with 54 additions and 2 deletions

View file

@ -6,4 +6,57 @@ Implementations of priority queues in Python using Rust bindings for speed.
I'm doing this to learn Rust, so don't judge me too hard lol.
I've noted a few places where I'm unhappy with the implementation (mostly w.r.t. code duplication), but hopefully as I become more comfortable in Rust I can go back and fix those.
Better to have a bad implementation now than a good implementation never is my view.
Better to have a bad implementation now than a good implementation never.
## Usage
The package provides 3 queues: `Pure`, `Paired`, and `Indexed`, all of which are min-queues.
The `PureQueue` directly sorts the values it is given and returns them in order.
The `PairedQueue` pairs an arbitrary Python object with a float priority and returns the objects in the order specified by their priorities.
The `IndexedQueue` works the same as the `PairedQueue`, but allows arbitrary priority modification and object deletion at the cost of some runtime overhead and no support for duplicate objects (duplicate priorities are okay).
Typing is provided in `pyority_queue.pyi`, and should be picked up by your IDE.
## Development
Install venv and setup as usual
```sh
python -m venv venv
pip install -r requirements.txt
source venv/bin/activate
```
Build rust code with
```sh
maturin develop
```
Note that after you build the project for the first time you may have to restart the venv for it to pick up the new module
```sh
deactivate
source venv/bin/activate
```
Develop as usual, you should now be able to import the code through Python
```py
from pyority_queue import *
```
### Testing
Run the rust test suite with
```sh
cargo test
```
Run the python test suite with
```sh
pytest tests/*.py
```

View file

@ -2,5 +2,4 @@ iniconfig==2.0.0
maturin==1.8.1
packaging==24.2
pluggy==1.5.0
-e git+ssh://git@git.mmbradley.ca:222/MichaelBradley/pyority_queue.git@661e1d220ae71002d66d2ba2d3dfddfe4ff1035d#egg=pyority_queue
pytest==8.3.4