Ordered Multivalue Dictionary

1.0.2 · maintenance · verified Thu Apr 09

orderedmultidict is a Python library that provides an `omdict` class, an ordered multivalue dictionary. It retains the insertion order of both keys and their associated values, and aims for method parity with Python's built-in `dict`. The library is known for powering `furl` and supports both Python 2 and Python 3 environments. The current version is 1.0.2, with the last release dating back to 2019, indicating an infrequent release cadence.

Warnings

Install

Imports

Quickstart

Demonstrates basic instantiation, adding multiple values to a key, and accessing values while preserving insertion order.

from orderedmultidict import omdict

# Create an empty ordered multivalue dictionary
omd = omdict()

# Add values for keys
omd[1] = 'apple'
omd.add(2, 'banana')
omd.add(1, 'apricot') # Add another value for key 1

# Access values
print(omd[1]) # Accesses the first value for key 1: 'apple'
print(omd.getlist(1)) # Gets all values for key 1: ['apple', 'apricot']

# See insertion order
print(list(omd.keys())) # Keys in insertion order: [1, 2, 1]
print(list(omd.items())) # Items in insertion order: [(1, 'apple'), (2, 'banana'), (1, 'apricot')]

view raw JSON →