Metadata-Version: 2.4
Name: rs-avl
Version: 0.1.0
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Typing :: Typed
License-File: LICENSE-GPL-3.0
License-File: LICENSE-APACHE-2.0
Summary: A fast AVL ordered set backed by Rust
Home-Page: https://github.com/anuradhawick/rs-avl
License-Expression: GPL-3.0-only OR Apache-2.0
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Project-URL: Documentation, https://docs.rs/rs-avl
Project-URL: Homepage, https://github.com/anuradhawick/rs-avl
Project-URL: Issues, https://github.com/anuradhawick/rs-avl/issues
Project-URL: Repository, https://github.com/anuradhawick/rs-avl

# rs-avl for Python

[![PyPI](https://img.shields.io/pypi/v/rs-avl.svg)](https://pypi.org/project/rs-avl/)
[![Python](https://img.shields.io/pypi/pyversions/rs-avl.svg)](https://pypi.org/project/rs-avl/)
[![Publish PyPI](https://github.com/anuradhawick/rs-avl/actions/workflows/pypi.yml/badge.svg)](https://github.com/anuradhawick/rs-avl/actions/workflows/pypi.yml)

A fast AVL ordered set backed by Rust, with support for arbitrary comparable
Python objects.

## Installation

```bash
pip install rs-avl
```

## Comparable values

```python
from rs_avl import AVLTree

tree = AVLTree([4, 2, 6, 1, 3, 5])
tree.insert(7)

assert list(tree) == [1, 2, 3, 4, 5, 6, 7]
assert tree.search(3) == 3
assert list(tree.range(2, 6)) == [2, 3, 4, 5]
```

## Objects ordered by an attribute

```python
from dataclasses import dataclass
from rs_avl import AVLTree

@dataclass
class Task:
    name: str
    priority: int

tasks = AVLTree(
    [Task("document", 2), Task("release", 1)],
    key="priority",
)

assert tasks.first().name == "release"
assert tasks.search_key(2).name == "document"
```

`key` can also be a callable, including a lambda returning a composite key:

```python
tasks = AVLTree(key=lambda task: (task.priority, task.name))
```

Equal keys are treated as duplicates. Extracted keys should remain comparable
for as long as their values are stored. Type information is included through a
generated `.pyi` file and `py.typed` marker.

## License

Dual-licensed under your choice of GPL-3.0-only or Apache-2.0.

