Skip to main content

PyPI version Doc Status License PyPI - Downloads

orderedsets

An implementation of mutable and immutable ordered sets as thin wrappers around Python's dict class. These classes are meant as drop-in replacements for Python's builtin set and frozenset classes. Care has been taken to provide the same functionality as the Python classes, without API additions or removals, to allow easy switching between set implementations. These classes are often faster than other ordered set implementations (but slower than Python's builtin sets).

In contrast to Python's builtin set and frozenset classes, the order of items is kept (generally, insertion order), such that iterating over items in the set as well as mutating operations are deterministic.

This package has no external dependencies.

Usage

Install this package with:

$ pip install orderedsets

Usage example:

from orderedsets import OrderedSet, FrozenOrderedSet

os = OrderedSet([1, 2, 4])
os.add(0)
assert list(os) == [1, 2, 4, 0]
os.remove(0)

fos = FrozenOrderedSet([1, 2, 4])
# a.add(0)  # raises AttributeError: 'FrozenOrderedSet' object has no attribute 'add'
assert list(fos) == [1, 2, 4]

# sets with the same elements compare equal
assert os == fos == set([1, 2, 4]) == frozenset([1, 2, 4])

# only immutable sets can be hashed
assert hash(fos) == hash(frozenset([1, 2, 4]))

Please also see the documentation.

References

Other packages

Discussions

Python implementations

Metadata

Release files for orderedsets 2026.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for orderedsets 2026.1
File Interpreter ABI Platform
orderedsets-2026.1-py3-none-any.whl Python 3 none any Details

Release files / orderedsets-2026.1-py3-none-any.whl

Download URL orderedsets-2026.1-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eeba66599de8822a13e507cb9f10169cef7f0fd627cafe398e5c0d6a4f1db8b7
BLAKE2b-256 checksum
How to use checksums
cb0be2e6fbc93e8e84170db56653af570bc7205f706d5174f5bfba294c317e4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release history Release notifications | RSS feed

This release

2026.1 This release

1 release file

2025.2

1 release file

2025.1

1 release file

2024.2

1 release file

2024.1

1 release file

2024.0

1 release file

2023.3

1 release file

2023.2

1 release file

2023.1

1 release file

2023.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page