{"id":673,"library":"orderly-set","title":"Orderly Set","description":"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.","status":"active","version":"5.5.0","language":"python","source_language":"en","source_url":"https://github.com/seperman/orderly-set","tags":["set","ordered","data structure","collection","performance"],"install":[{"cmd":"pip install orderly-set","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"Beware of other 'ordered set' libraries on PyPI with similar names but different import paths and implementations.","wrong":"from orderedset import OrderedSet","symbol":"OrderedSet","correct":"from orderly_set import OrderedSet"},{"symbol":"StableSet","correct":"from orderly_set import StableSet"},{"symbol":"RoughMaxSizeSet","correct":"from orderly_set import RoughMaxSizeSet"},{"note":"Note the capitalization: `OrderlySet` is a specific class within the `orderly_set` package, distinct from `OrderedSet`.","symbol":"OrderlySet","correct":"from orderly_set import OrderlySet"}],"quickstart":{"code":"from orderly_set import OrderedSet, StableSet\n\n# Using OrderedSet\nletters = OrderedSet('abracadabra')\nprint(f\"OrderedSet: {letters}\")  # Expected: OrderedSet(['a', 'b', 'r', 'c', 'd'])\nprint(f\"'r' in letters: {'r' in letters}\")\nprint(f\"Index of 'r': {letters.index('r')}\")\nprint(f\"Item at index 2: {letters[2]}\")\nletters.add('x')\nprint(f\"After adding 'x': {letters}\")\n\n# Using StableSet (different performance characteristics)\nstable_items = StableSet([1, 5, 2, 5, 3])\nprint(f\"StableSet: {stable_items}\") # Expected: StableSet({1, 5, 2, 3})\nstable_items.add(4)\nprint(f\"After adding 4: {stable_items}\")","lang":"python","description":"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."},"warnings":[{"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'.","message":"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.","severity":"breaking","affected_versions":">=5.4.0"},{"fix":"Always use `from orderly_set import [ClassName]` for `orderly-set`. If you intend to use a different library, verify its specific import path.","message":"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.","severity":"gotcha","affected_versions":"All"},{"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.","message":"The `OrderedSet` class within `orderly-set` has O(N) deletion performance, which can be a bottleneck for applications with frequent deletions on large sets.","severity":"gotcha","affected_versions":"All"},{"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.","message":"The `StableSet` class within `orderly-set` has O(N) index lookup performance.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-05-12T17:43:32.286Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"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`).","cause":"The 'orderly-set' package is either not installed, or there is a typo in the import statement.","error":"ModuleNotFoundError: No module named 'orderly_set'"},{"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`.","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.","error":"from ordered_set import OrderedSet"},{"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.","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.","error":"AttributeError: 'OrderlySet' object has no attribute 'items'"},{"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.","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.","error":"AttributeError: 'OrderedSet' object has no attribute 'append'"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":80,"quickstart_tag":"verified","pypi_latest":"5.5.0","install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.6,"disk_size":"17.9M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.6,"disk_size":"17.9M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.5,"import_time_s":0.01,"mem_mb":0.6,"disk_size":"18M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.6,"disk_size":"18M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.02,"mem_mb":0.8,"disk_size":"19.7M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.02,"mem_mb":0.8,"disk_size":"19.7M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.6,"import_time_s":0.02,"mem_mb":0.8,"disk_size":"20M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.02,"mem_mb":0.8,"disk_size":"20M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.7,"disk_size":"11.6M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.02,"mem_mb":0.7,"disk_size":"11.6M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.4,"import_time_s":0.01,"mem_mb":0.7,"disk_size":"12M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.7,"disk_size":"12M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.02,"mem_mb":0.8,"disk_size":"11.3M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.8,"disk_size":"11.2M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.4,"import_time_s":0.01,"mem_mb":0.6,"disk_size":"12M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.6,"disk_size":"12M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.6,"disk_size":"17.4M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.6,"disk_size":"17.4M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.7,"import_time_s":0.01,"mem_mb":0.6,"disk_size":"18M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.6,"disk_size":"18M"}]},"quickstart_checks":{"last_tested":"2026-04-24","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}