Skip to main content
Test PyPI package

Introduction

indexed.IndexedOrderedDict (alias indexed.Dict) is feature compatible with collections.OrderedDict as of Python 3.11 and can be used as a drop in replacement. The main difference is that key, value and item views support accessing elements by their index.

d = indexed.IndexedOrderedDict()
d["first-key"] = "first-value"
d["second-key"] = "second-value"
d["third-key"] = "third-value"

values = d.values()
assert values[2] == "third-value"

assert d.keys().index("second-key") == 1

Features

  • Access keys, values and items by index, e.g., d.keys()[5].

  • Find the index of a key, e.g., d.keys().index("key").

  • Sort keys in place, e.g., d.sort().

Excluding those additions the API is the same as the API of collections.OrderedDict().

Installing

pip install indexed

Performance

Performance is practically on the same order of magnitude as the built in collections.OrderedDict, with exceptions in bold:

d

collections.OrderedDict

indexed.IndexedOrderedDict

Operation

Avergage

Worst case

Average

Worst case

d.copy()

O(n)

O(n)

O(n)

O(n)

d[key]

O(1)

O(n)

O(1)

O(n)

d[key] = value

O(1)

O(n) [1]

O(1)

O(n) [1]

del d[key]

O(1)

O(n)

O(n)

O(n)

d.keys()[i]

O(n) [2]

O(n) [2]

O(1)

O(1)

d.values()[i]

O(n) [3]

O(n) [3]

O(1)

O(n)

d.items()[i]

O(n) [3]

O(n) [3]

O(1)

O(n)

d.keys().index(x)

O(n) [3]

O(n) [3]

O(n)

O(n)

License

This library is derived from CPython’s collections.OrderedDict and licensed under the PSFL. See the LICENSE file for the full license text.

Metadata

Release files for indexed 1.3.0

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

Source distribution (sdist)

Source distribution for indexed 1.3.0
File Size Uploaded Provenance
indexed-1.3.0.tar.gz 5.5 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 11.1 kB

Release files / indexed-1.3.0.tar.gz

Download URL indexed-1.3.0.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6a0dd1f164db2eef6f9983bf1c5302d4b250a05b784f15c4c3f436d8778243d9
BLAKE2b-256 checksum
How to use checksums
0791ebbff25d520fd4c904fcec67a1e4800c6e37c17f4c64057693e38aa2455b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.8

Release files / indexed-1.3.0-py3-none-any.whl

Download URL indexed-1.3.0-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a35db8644bef9273be710f5f06b5ffe71b8699d9212593cbae422b5e3c5f64c6
BLAKE2b-256 checksum
How to use checksums
628be5c5af4bb7f87409afd3addd3612bc471b2e141987d3edf64c7693cae7c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.8

Security for indexed 1.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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