skillfed

optionaldict

A dict-like object that ignore NoneType values for Python

optionaldict v0.1.2 157.5K downloads/30d#10,754 on PyPI5
Permissive license Abandoned released

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 optionaldict

uv

uv add optionaldict

poetry

poetry add optionaldict

Installing 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

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: MacOSOperating System :: POSIXOperating System :: POSIX :: LinuxProgramming Language :: PythonProgramming Language :: Python :: 2.6Programming Language :: Python :: 2.7Programming Language :: Python :: 3.2Programming Language :: Python :: 3.3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python ModulesTopic :: Utilities

Tags

dict that ignores none valuesoptional dict pythondict without none keysnone-filtering dictionaryjson serializable dictpicklable dictsparse dict implementation
data-structureserialization

More Libraries packages