Registry / serialization / deflate-dict

deflate-dict

JSON →
library1.2.2pypypi✓ verified 87d ago

A Python library for inflating and deflating nested dictionaries. Deflate flattens nested dicts into key paths, and inflate reverses the process. Current version 1.2.2, stable maintenance.

pip install deflate-dict
INSTALL
IMPORT
SIG · DEFLATE-DICT
D
deflate-dict
serializationpythonv1.2.2
Install
2.4s avg
Import
12ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.2.2 · 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.012s · 19.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.4s · import 0.012s · 20MB
17MB installed
● package 17MB
Code
Verified usage

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

deflate
from deflate_dict import deflate
from deflate_dict.deflate import deflate
Top-level import is preferred.
inflate
from deflate_dict import inflate
from deflate_dict.inflate import inflate
Top-level import is preferred.

Deflate a nested dict and inflate it back.

from deflate_dict import deflate, inflate nested = {'a': {'b': 1, 'c': 2}} flat = deflate(nested) print(flat) # {'a.b': 1, 'a.c': 2} restored = inflate(flat) print(restored) # {'a': {'b': 1, 'c': 2}}
Debug
Known issues
gotchaDefault separator is '.' which can clash with keys containing dots. Use `separator` parameter to choose a safe delimiter.
fix
deflate(nested, separator='__') or inflate(flat, separator='__')
affects: all
gotchaInflation assumes no overlapping key paths. If a flattened key like 'a.b' and a nested key like 'a' with value exist, behavior may be unexpected.
fix
Ensure no ambiguous key patterns before inflating.
affects: all
gotchaThe library does not handle non-string keys for deflation. Keys must be strings or convertible to strings.
fix
Convert non-string keys to strings before deflating.
affects: all
Errors
Common errors & fixes
TypeError: unhashable type: 'list'
Passing a list as a value deeply nested; deflate expects dicts as nested structures.
fix
Ensure nested values are dicts, not lists. Wrap lists in a dict if needed.
KeyError: 'some.path'
Inflation attempted on a flat dict missing some expected keys or using wrong separator.
fix
Check that the flat dict contains keys exactly matching the deflated output, or use custom separator consistently.
Upgrade
Version history
1.2.2latest on PyPI · released Oct 26, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
deflate-dict — pip install deflate-dict · libregistry