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-setVerified import paths — ran on the pinned version, not inferred.
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.
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'.
Always use `from orderly_set import [ClassName]` for `orderly-set`. If you intend to use a different library, verify its specific import path.
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.
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.
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`).
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`.
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.
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.
No dependency data recorded yet.