Registry / data / orderly-set

orderly-set

JSON →
library5.5.0pypypi✓ verified 24d ago

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
INSTALL
IMPORT
SIG · ORDERLY-SET
O
orderly-set
datapythonv5.5.0
Install
1.5s avg
Import
13ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v5.5.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.014s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.012s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

OrderedSet
from orderly_set import OrderedSet
from orderedset import OrderedSet
Beware of other 'ordered set' libraries on PyPI with similar names but different import paths and implementations.
StableSet
from orderly_set import StableSet
RoughMaxSizeSet
from orderly_set import RoughMaxSizeSet
OrderlySet
from orderly_set import OrderlySet
Note the capitalization: `OrderlySet` is a specific class within the `orderly_set` package, distinct from `OrderedSet`.

This quickstart demonstrates the creation and basic operations of `OrderedSet` and `StableSet`. `OrderedSet` acts like a hybrid of a list and a set, preserving insertion order with efficient index lookup but O(N) deletion. `StableSet` provides fast O(1) insertion, deletion, and membership testing, but O(N) index lookup.

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}")
Debug
Known issues
breakingVersion 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'.
affects: >=5.4.0
gotchaThere 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.
affects: All
gotchaThe `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.
affects: All
gotchaThe `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.
affects: All
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'orderly_set'
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`).
from ordered_set import OrderedSet
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`.
AttributeError: 'OrderlySet' object has no attribute 'items'
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.
AttributeError: 'OrderedSet' object has no attribute 'append'
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.
Upgrade
Version history
5.5.0latest on PyPI · released Jul 10, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
orderly-set — pip install orderly-set · libregistry