Skip to main content

multiset-key-dict

This small library implements a mapping-like object whose keys are taken to be unordered multisets (Counters, bags), regardless of the type of the actual indexes used.

Example

Create a MultisetKeyDict and insert an element for the set {1, 3, 5}.

from multiset_key_dict import MultisetKeyDict
mskd = MultisetKeyDict()
mskd[[1, 3, 5]] = 19

Access the element just added.

# In a different order.
print(mskd[[3, 5, 1]]) # 19
# With a different type of collection.
print(mskd[{3, 5, 1}]) # 19

__iter__ iterates over items in the MultisetKeyDict, viewed as frozensets (i.e., not accounting for multiplicity).

# Add more data.
mskd[[1]] = 9
mskd[[5, 6]] = 12
print(list(mskd)) # [(frozenset({1, 3, 5}), 19), (frozenset({1}), 9), (frozenset({5, 6}), 12)]

To iterate over key-value pairs where the keys are the FrozenMultiset objects that act as the true keys in the structure, use multiset_iter or items methods instead.

mskd[[1, 1]] = 90
print(list(mskd))
# [(frozenset({1, 3, 5}), 19), (frozenset({1}), 9), (frozenset({5, 6}), 12),
# (frozenset({1}), 90)]

print(list(mskd.multiset_iter()))
# [(FrozenMultiset({(3, 1), (1, 1), (5, 1)}), 19), 
#  (FrozenMultiset({(1, 1)}), 9),
#  (FrozenMultiset({(6, 1), (5, 1)}), 12),
#  (FrozenMultiset({(1, 2)}), 90)]

To get the keys as frozenset objects, use set_keys. To get the keys as FrozenMultiset objects, use multiset_keys or keys.

It's sometimes useful to get the set of elements of the keys. For that, you can use the key_elements method.

print(mskd.key_elements()) # frozenset({1, 3, 5, 6})

Metadata

Release files for multiset-key-dict 0.2.3

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

Source distribution (sdist)

Source distribution for multiset-key-dict 0.2.3
File Size Uploaded Provenance Actions
multiset_key_dict-0.2.3.tar.gz 5.3 kB With provenance Details for multiset_key_dict-0.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for multiset-key-dict 0.2.3
File Interpreter ABI Platform Actions
multiset_key_dict-0.2.3-py3-none-any.whl Python 3 none any Details for multiset_key_dict-0.2.3-py3-none-any.whl

Total release size: 10.9 kB

Release files / multiset_key_dict-0.2.3.tar.gz

Download URL multiset_key_dict-0.2.3.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c80a9d25f12a34e5ef87bd49ba77501985cdf50a066378686a6f97a425027834
BLAKE2b-256 checksum
How to use checksums
309e3580d5f15c358c84996e3b6eae5872430c399dca8f323b92c3f8698c4af5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 7, 2026.

Transparency log

Release files / multiset_key_dict-0.2.3-py3-none-any.whl

Download URL multiset_key_dict-0.2.3-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cfa0cf111b03d38a23b554ae75aed822611510a3275c8766240e264973dfcf2c
BLAKE2b-256 checksum
How to use checksums
27217c604dd1fb1070795a4c1c160073ba15fb635f32dc79d5423b106d878980
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 7, 2026.

Transparency log

Security for multiset-key-dict 0.2.3

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for multiset_key_dict-0.2.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 7, 2026.

Transparency log

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