Skip to main content

A strongly typed list of dictionaries data type with validation and serialization support.

Project description

listofdicts

PyPI version License: MIT

Enterprise-grade strongly-typed [list of dictionaries] for Python


Summary

listofdicts is a powerful custom Python list-of-dicts data structure designed for modern AI automation, data processing, data pipelines, API layers, and JSON-based applications where structured lists of dictionaries are commonly used.


Key Features

  • ✅ Restrict types to list of dictionary objects
  • ✅ Optional schema validation.
  • ✅ Optional immutability (lock data after loading).
  • ✅ Full JSON serialization/deserialization.
  • ✅ Supports deep copying and safe mutations.
  • ✅ Strict runtime type safety.
  • ✅ Merge and update support.

Installation

pip install listofdicts

Usage

from listofdicts import listofdicts

# Define schema for safety
schema = {
    'id': int,
    'name': str,
    'active': bool
}

lod = listofdicts([
    {'id': 1, 'name': 'Alice', 'active': True},
    {'id': 2, 'name': 'Bob', 'active': False}
], schema=schema)

# Append valid
lod.append({'id': 3, 'name': 'Carol', 'active': True})

# Partial update
lod.update_item(0, {'active': False})

# Merge with another listofdicts
lod2 = listofdicts([
    {'id': 4, 'name': 'Eve', 'active': True}
], schema=schema)

merged = lod.merge(lod2)

# Serialize to JSON
json_str = merged.to_json(indent=2)

# Deserialize from JSON
restored = listofdicts.from_json(json_str, schema=schema)

print(restored)

API Summary

listofdicts
Method Description
append() Append a validated dictionary
extend() Extend with another
merge() Merge two instances
update_item() Partially update an entry
copy() Deep copy
as_mutable() Return mutable copy
as_immutable() Return immutable copy
to_json() Serialize to JSON
from_json() Deserialize from JSON
immutable Property to check mutability
schema Property to access schema

Directory Structure

listofdicts/
    ├── src/
    │   ├── __init__.py
    │   └── listofdicts.py
    ├── tests/
    │   └── test_listofdicts.py
    ├── README.md
    ├── pyproject.toml
    ├── setup.cfg
    └── LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

listofdicts-1.1.0.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

listofdicts-1.1.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file listofdicts-1.1.0.tar.gz.

File metadata

  • Download URL: listofdicts-1.1.0.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for listofdicts-1.1.0.tar.gz
Algorithm Hash digest
SHA256 967b41e532031bafadcf5c20167e7039054cfcb61b52728c4567d525e5bde056
MD5 0b4903774fe449d9e012480abc743a38
BLAKE2b-256 21a67021e9ee5bc622f42210b2d32f0e0e626a54903345003dbc6048798b5d95

See more details on using hashes here.

File details

Details for the file listofdicts-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: listofdicts-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for listofdicts-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9322f6f95be05eeecefba5b3e8ce4ff18c9fa50ead5bfc11f130c5bc8a69d4f1
MD5 829dbac45e7f4ea5dc83c27a1dfc3a0a
BLAKE2b-256 867068fbcee58c48ef193b68dedcafacdc1917b8ec442b10f3e6f61eaee3f0c2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page