Registry / serialization / multi-key-dict

multi-key-dict

JSON →
library2.0.3pypypi✓ verified 23d ago

multi-key-dict (version 2.0.3) is a Python library that provides a dictionary implementation allowing multiple distinct keys to refer to the same single value. It extends the standard dictionary interface to enable access, update, and deletion of elements via any of its associated keys. The library appears to be in maintenance mode, with its last release in 2015.

pip install multi-key-dict
INSTALL
IMPORT
SIG · MULTI-KEY-DICT
M
multi-key-dict
serializationpythonv2.0.3
Install
2.4s avg
Import
11ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.0.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.010s · 19.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.4s · import 0.008s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

multi_key_dict
from multi_key_dict import multi_key_dict
The primary class to import is 'multi_key_dict'.

This example demonstrates how to create a multi-key dictionary, assign a value using multiple keys, access the value via any of its keys, update the value through one key (affecting all associated keys), and delete the value through one key (making it inaccessible via others).

from multi_key_dict import multi_key_dict k = multi_key_dict() k[1000, 'kilo', 'k'] = 'kilo (x1000)' print(f"Value for key 1000: {k[1000]}") print(f"Value for key 'k': {k['k']}") k['kilo'] = 'kilo' print(f"Updated value for key 1000: {k[1000]}") del k[1000] # Accessing any other key will now raise a KeyError as the value is deleted try: print(k['kilo']) except KeyError as e: print(f"Accessing 'kilo' after deleting by 1000: {e}")
Debug
Known issues
gotchaThis library enables multiple *keys* to point to a *single value*. It is not designed for a single key to hold multiple values (like the `multidict` library does for HTTP headers). Attempting to store multiple values for one key will overwrite previous values.
fix
Understand the core functionality: multi-key-dict maps multiple distinct keys to one unique value. If you need a key to map to a list of values, consider using `list` as a value or explore other 'multidict' implementations if that is the desired behavior.
affects: All versions
gotchaUpdating a value using any of its associated keys will change the single underlying value. All other keys linked to that original value will then reflect the new updated value.
fix
Be aware that keys associated with the same value are linked. An update operation on any one of these keys will propagate to all other linked keys. Test thoroughly if this behavior is unexpected for your use case.
affects: All versions
gotchaDeleting an item via one of its associated keys will remove the underlying value entirely. Consequently, the value will no longer be accessible through any other key that was previously linked to it, resulting in a KeyError.
fix
When deleting an item, understand that you are deleting the shared value, not just the association with a single key. Ensure this is the intended side effect across all linked keys.
affects: All versions
deprecatedThe latest release of multi-key-dict (2.0.3) was published in 2015, indicating a very slow development or maintenance-only cadence. While functional, it might not receive frequent updates or new features.
fix
Assess if the current feature set meets your long-term needs. Consider potential compatibility issues with newer Python versions, though `requires_python: None` suggests broad compatibility. Monitor the GitHub repository for any new activity.
affects: 2.0.3 and older
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'multi_key_dict'
The 'multi_key_dict' package is not installed in your Python environment or the environment where your script is being run.
fix
Install the package using pip: `pip install multi-key-dict`
KeyError: 'some_key'
You attempted to access a value using a key that has not been associated with any value in the multi-key dictionary.
fix
Ensure the key (or one of its aliases) exists in the dictionary before attempting to access it, for example, by using `if 'some_key' in my_mkey_dict:` or `my_mkey_dict.get('some_key', default_value)`.
AttributeError: 'multi_key_dict' object has no attribute 'append'
You are attempting to use a list method (`append`) directly on the `multi_key_dict` object itself, or on a value retrieved from it that is not a list. The `multi_key_dict` stores single values per set of keys.
fix
To add or update a value, use assignment `my_mkey_dict[key] = new_value`. If you intend to store multiple items under a key, ensure the value itself is a list (or other mutable collection) and append to that: `my_mkey_dict[key].append(item)`.
ImportError: cannot import name 'MultiKeyDict' from 'multi_key_dict'
You are attempting to import a class named 'MultiKeyDict' (with a capital 'M') when the library's primary dictionary class is named 'multi_key_dict' (lowercase 'm') within the module.
fix
Use the correct import statement as shown in the library's examples: `from multi_key_dict import multi_key_dict`
Upgrade
Version history
2.0.3latest on PyPI · released Sep 20, 2015
Audit
Dependencies

No dependency data recorded yet.

Agent activity
19 hits · last 30 days
node
18
Resources