A dead simple set that preserves insertion order, internally using the python’s 3.7 dict, which preserves order.
pip install ordered-set-37
This class subclasses and implements all the methods of MutableSet.
from ordered_set_37 import OrderedSet
x = OrderedSet([1, 2, -1, "bar"])
x.add(0)
assert list(x) == [1, 2, -1, "bar", 0]
This library uses the typing system, so feel free to do:
x: OrderedSet[str] = OrderedSet(("foo", "bar"))
x.add(1) # type checkers won't like this as it is not a string
As an extra, you can access a value by index (although the speed is at worst O(n)):
x = OrderedSet(["foo", "bar", "baz"])
assert x[1] == "bar"
For obvious reasons, this library is only Python 3.7+ compatible.
Feel free to contribute, fork, etc.
Release files for Ordered-set-37 2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| Ordered-set-37-2.0.tar.gz | 3.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| Ordered_set_37-2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.0 kB
Release files / Ordered-set-37-2.0.tar.gz
| Download URL | Ordered-set-37-2.0.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b44a4e49c25af5a6f73d6e683851faedacf8f2464d5379883ca5b2f11e978f80
|
|
BLAKE2b-256 checksum How to use checksums |
15fef701adfb319cf28be4a0b3422fea091dfd2a67a5b95db85089301c116536
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/62.3.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.13
|
Release files / Ordered_set_37-2.0-py3-none-any.whl
| Download URL | Ordered_set_37-2.0-py3-none-any.whl |
|---|---|
| Size | 3.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
994cb95b9fc788fd8b5cc1741f98ced43c85b5b412a988745d16c66d1d77a9ad
|
|
BLAKE2b-256 checksum How to use checksums |
468ddf7f804b42c54c2e3cfc0e5408ea69fb06f8101dc03105f10d410e2cc69e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/62.3.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.13
|