Skip to main content

Dead simple & fast ordered set using python's 3.7+ dict.

Project description

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.

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Ordered-set-37-1.0.tar.gz (2.8 kB view details)

Uploaded Source

File details

Details for the file Ordered-set-37-1.0.tar.gz.

File metadata

  • Download URL: Ordered-set-37-1.0.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.8

File hashes

Hashes for Ordered-set-37-1.0.tar.gz
Algorithm Hash digest
SHA256 04ce2592c7ef6db7a2e57ab1c14175fea6980dd78b0ddc03b9b9c8004cc3d48b
MD5 839de9d738873e13cc704db764c68946
BLAKE2b-256 5b9bdd8c8ee54d98576895b39129a6371ced1701c190913b65953fa79e0a8e81

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page