Ordered set for Python implemented in Rust (PyO3 + indexmap).
Same with the original set + pop(index: int) and remove(item)
other in set operations can be an OrderedSet or any iterable.
uv sync --all-extras
uv run maturin develop --releasefromfast_ordsetimportOrderedSets=OrderedSet()
s.add(1)
s.add(2)
s.add(1)
assertlen(s) ==2assert1insasserts[0] ==1asserts[-1] ==2assertlist(s) == [1, 2]
s.update([3, 2, 4])
s.remove(2)
x=s.pop() # 4 (last inserted)The extension is built to be thread-safe and declares that it does not rely on the GIL. You can use it with a free-threaded (no-GIL) Python build so that the interpreter does not re-enable the GIL when this module is imported.
./scripts/debug.sh- Scripts — build, test, and benchmark scripts
- Benchmarks — performance and memory benchmarks
- Development — setup, build, and contribution