Skip to main content

techcable.orderedset

github pypi types]

A simple and efficient OrderedSet in pure python. Implements both MutableSet and Sequence.

Example Usage

from techcable.orderedset import OrderedSet

# prints {1, 2, 7, 3}
print(OrderedSet([1, 2, 7, 2, 3]))
# Implements all standard set methods, still preserves order
print(OrderedSet.of[1,2]) | OrderedSet([3,2,4]))  # {1,2,3,4}
# OrderedSet.of(1, 2) is shorthand for OrderedSet([1, 2]),
# avoiding an extra pair of brackets
print(OrderedSet.of(1, 2)) # {1, 2}


# Implements `append` method, returning True on success
# and False if the item was a duplicate
oset = OrderedSet()
oset.append(1) # True
oset.append(2) # True
oset.append(1) # False - already in set, did nothing
oset.extend([2,3]) # True - at least one success
oset.append([2,3]) # False - all duplicates

Supports pydantic validation & serialization:

import pydantic
from techcable.orderedset import OrderedSet

model = pydantic.TypeAdapter(OrderedSet[int])
# prints OrderedSet.of(1,2,7,8)
print(repr(model.validate_python([1,2,7,8])))
assert model.dump_python(OrderedSet.of(1,2,7,8)) == [1,2,7,8]

Potential Future Features

  • Implement OrderedFrozenSet
  • Consider acceleration module using C/Rust/Cython
    • Probably unnecessary since this has library has very little overhead compared to the builtin set/list

License

Licensed under either the Apache 2.0 License or MIT License at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Metadata

Release files for techcable.orderedset 0.1.8

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

Source distribution (sdist)

Source distribution for techcable.orderedset 0.1.8
File Size Uploaded
techcable_orderedset-0.1.8.tar.gz 16.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for techcable.orderedset 0.1.8
File Interpreter ABI Platform
techcable_orderedset-0.1.8-py3-none-any.whl Python 3 none any Details

Total release size: 30.0 kB

Release files / techcable_orderedset-0.1.8.tar.gz

Download URL techcable_orderedset-0.1.8.tar.gz
Size 16.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7cf9316e8c069a3bafc3b09fe27966ab9744dcddb5247bfe2a88588b48a486b7
BLAKE2b-256 checksum
How to use checksums
c4d39c1d47c5c963737373dffe108108cc5f8cd368d10db4d65253000c14a386
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release files / techcable_orderedset-0.1.8-py3-none-any.whl

Download URL techcable_orderedset-0.1.8-py3-none-any.whl
Size 13.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
829b74d37a54a2067c1c3560900d82199bd81114b4bed45efdb9fff5f6085f78
BLAKE2b-256 checksum
How to use checksums
05d56cfb6a823881a56398b8a5df3eab836898b4c64a8935ce77f1ae52ecf8ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release history Release notifications | RSS feed

This release

0.1.8 This release

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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