Orderly Set
raw JSON → 5.5.0 verified Tue May 12 auth: no python install: verified quickstart: verified
Orderly Set is a Python package providing several implementations of ordered set data structures, including `OrderlySet`, `StableSet`, `StableSetEq`, `OrderedSet`, and `RoughMaxSizeSet`. These implementations combine the uniqueness of a set with the order-preserving characteristics of a list or sequence, offering various performance trade-offs for operations such as insertion, deletion, membership testing, and index lookups. The library is actively maintained, with its current version being 5.5.0, and receives regular updates as evidenced by its GitHub release history.
pip install orderly-set Common errors
error ModuleNotFoundError: No module named 'orderly_set' ↓
cause The 'orderly-set' package is either not installed, or there is a typo in the import statement.
fix
Ensure the package is installed using
pip install orderly-set and the import statement is from orderly_set import OrderlySet (or other classes like OrderedSet). error from ordered_set import OrderedSet ↓
cause This is a common wrong import pattern because there is another, similarly named package called 'ordered-set'. If 'orderly-set' is installed, this import will fail.
fix
If you intend to use the
orderly-set library, change the import to from orderly_set import OrderedSet (or the specific class you need from 'orderly_set'). If you intend to use the 'ordered-set' library, install it with pip install ordered-set. error AttributeError: 'OrderlySet' object has no attribute 'items' ↓
cause Users sometimes confuse `OrderlySet` (or other ordered set implementations within the library) with Python's built-in `dict` type and attempt to call dictionary-specific methods like `items()` on it. An `OrderlySet` is a set-like object, not a dictionary.
fix
Access elements directly by iterating over the set or by using set-specific methods. If you need key-value pairs, consider using a dictionary or a custom class that wraps both
OrderlySet and a dictionary. error AttributeError: 'OrderedSet' object has no attribute 'append' ↓
cause Users might treat an `OrderedSet` (or other ordered set implementations within the library) like a Python `list` and try to use list-specific methods such as `append()`. While `OrderedSet` maintains order, it is fundamentally a set and does not support list modification methods.
fix
Use set-specific methods like
.add() for adding elements or convert the set to a list if you require list operations. Keep in mind that converting to a list will lose the uniqueness property if you modify the list and convert back to a set. Warnings
breaking Version 5.4.0 changed behavior for accessing multiple items, switching from a singular `index` method to `indexes` for iterable input. Code using `index` for multiple items may break. ↓
fix Review calls to `.index()` when attempting to retrieve multiple item indices. The documentation (or source) suggests `__getitem__()` and `index()` methods were extended to accept iterables for 'fancy indexing'.
gotcha There are several 'ordered set' libraries on PyPI (e.g., `orderedset` by simonpercivall, `ordered-set` by rspeer). Ensure you are importing from `orderly_set` as `from orderly_set import ...` to use this specific library. ↓
fix Always use `from orderly_set import [ClassName]` for `orderly-set`. If you intend to use a different library, verify its specific import path.
gotcha The `OrderedSet` class within `orderly-set` has O(N) deletion performance, which can be a bottleneck for applications with frequent deletions on large sets. ↓
fix For deletion-heavy workloads where insertion order must be maintained, consider `StableSet` which offers O(1) deletion, or evaluate if a standard `set` (unordered) or Python's built-in `dict` keys (ordered since 3.7 but without list-like indexing) might be more suitable.
gotcha The `StableSet` class within `orderly-set` has O(N) index lookup performance. ↓
fix If frequent lookups by index are critical, `OrderedSet` offers O(1) index lookup. Choose the implementation (`OrderedSet`, `StableSet`, etc.) that best fits your performance requirements for specific operations.
Install compatibility verified last tested: 2026-05-12
python os / libc status wheel install import disk
3.10 alpine (musl) wheel - 0.01s 17.9M
3.10 alpine (musl) - - 0.01s 17.9M
3.10 slim (glibc) wheel 1.5s 0.01s 18M
3.10 slim (glibc) - - 0.01s 18M
3.11 alpine (musl) wheel - 0.02s 19.7M
3.11 alpine (musl) - - 0.02s 19.7M
3.11 slim (glibc) wheel 1.6s 0.02s 20M
3.11 slim (glibc) - - 0.02s 20M
3.12 alpine (musl) wheel - 0.01s 11.6M
3.12 alpine (musl) - - 0.02s 11.6M
3.12 slim (glibc) wheel 1.4s 0.01s 12M
3.12 slim (glibc) - - 0.01s 12M
3.13 alpine (musl) wheel - 0.02s 11.3M
3.13 alpine (musl) - - 0.01s 11.2M
3.13 slim (glibc) wheel 1.4s 0.01s 12M
3.13 slim (glibc) - - 0.01s 12M
3.9 alpine (musl) wheel - 0.01s 17.4M
3.9 alpine (musl) - - 0.01s 17.4M
3.9 slim (glibc) wheel 1.7s 0.01s 18M
3.9 slim (glibc) - - 0.01s 18M
Imports
- OrderedSet wrong
from orderedset import OrderedSetcorrectfrom orderly_set import OrderedSet - StableSet
from orderly_set import StableSet - RoughMaxSizeSet
from orderly_set import RoughMaxSizeSet - OrderlySet
from orderly_set import OrderlySet
Quickstart verified last tested: 2026-04-24
from orderly_set import OrderedSet, StableSet
# Using OrderedSet
letters = OrderedSet('abracadabra')
print(f"OrderedSet: {letters}") # Expected: OrderedSet(['a', 'b', 'r', 'c', 'd'])
print(f"'r' in letters: {'r' in letters}")
print(f"Index of 'r': {letters.index('r')}")
print(f"Item at index 2: {letters[2]}")
letters.add('x')
print(f"After adding 'x': {letters}")
# Using StableSet (different performance characteristics)
stable_items = StableSet([1, 5, 2, 5, 3])
print(f"StableSet: {stable_items}") # Expected: StableSet({1, 5, 2, 3})
stable_items.add(4)
print(f"After adding 4: {stable_items}")