optionaldict
A dict-like object that ignore NoneType values for Python
What it is and what it does
optionaldict is a dict subclass that silently drops None values during assignment and storage, reducing boilerplate when building sparse data structures. It supports all standard dict operations and can be pickled or converted to JSON without special handling.
The package is minimal and dependency-free, making it trivial to install. However, it has not been maintained since January 2021, so there is no guarantee of compatibility with Python versions released after that date or any edge cases discovered in real-world use.
Use it for:
- Building API request payloads where None fields should be omitted rather than sent as null
- Storing configuration objects where unset options should not appear in serialized output
- Reducing conditional logic when constructing dictionaries with optional fields
- Creating sparse data structures for caching or logging without explicit None filtering
- Serializing model objects to JSON while automatically excluding unset attributes
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A dict subclass that automatically omits None values when storing or serializing, and is both picklable and JSON-serializable.
Yes, if you need a simple None-filtering dict for a new project and are comfortable with an unmaintained package. The code is straightforward enough that bugs are unlikely, but do not rely on it for critical systems or expect updates if incompatibilities emerge with future Python versions. For most use cases, a custom wrapper or a conditional dict comprehension is safer.
Install
optionaldict on PyPI
pip
pip install optionaldictuv
uv add optionaldictpoetry
poetry add optionaldictInstalling optionaldict
Before you install
Installation is frictionless—a pure-Python wheel with no runtime dependencies. However, the package has been abandoned since January 2021 (over 5 years without updates), so expect no bug fixes or compatibility work for newer Python versions.
License in practice
MIT license permits commercial and private use with minimal restrictions, requiring only attribution and inclusion of the license text.
Quickstart
pip install optionaldict
from optionaldict import optionaldict
d = optionaldict(a=1, b=None)
d['c'] = 2
print(d) # None values are omitted
Verify before relying
- Whether None-filtering behavior applies to all dict operations (update, fromkeys, etc.) or only direct assignment
- Whether the package works reliably with Python 3.10+ despite no updates since 2021
- JSON serialization behavior when nested structures contain None values
Package facts
| License | not declared (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | abandoned — 2,037 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 157,527/month — #10,754 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: optionaldict-0.1.2-py2.py3-none-any.whl
Keywords: dict, optional value
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
itypesProvides immutable container types (Dict and…
permissive · top 5,000 on PyPI
frozendictProvides an immutable, hashable dictionary…
copyleft · top 5,000 on PyPI
mo-dotsProvides null-safe dot-notation access to…
copyleft · top 15,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multidictMultidict is a dict-like container that allows…
permissive · top 100 on PyPI
sqlitedictProvides a dict-like interface to SQLite…
permissive · top 5,000 on PyPI
flatten-dictConverts nested dictionaries into flat…
permissive · top 5,000 on PyPI
orjsonorjson is a fast JSON serialization and…
copyleft · top 1,000 on PyPI
json-ref-dictProvides a dict-like interface to JSONSchema…
permissive · top 15,000 on PyPI