diff --git a/README.md b/README.md index 7e602aa..1576ae7 100644 --- a/README.md +++ b/README.md @@ -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 +```