picobox
Dependency injection framework designed with Python in mind.
What it is and what it does
Picobox is a dependency injection framework that decouples code by managing object creation and lifecycle through explicit registration in named boxes. You register values or factories into a box, then use decorators to inject them into functions—the framework handles scope management (singleton, threadlocal, contextvars) and ensures thread-safe access. It avoids implicit injection and complex dependency graphs in favor of pragmatic, explicit demands.
The framework is designed for developers who want clean decoupling without heavyweight machinery. It supports both static values and factory functions, allows you to push boxes onto a stack for context-aware resolution, and stays lightweight at ~500 lines of code with no external dependencies. It works across Python 3.8–3.12 and both CPython and PyPy.
Use it for:
- Inject configuration objects and database connections into request handlers in web applications.
- Manage thread-local or context-local service instances in multi-threaded or async codebases.
- Decouple business logic from external dependencies like HTTP clients or logging systems.
- Create testable code by swapping real implementations with mocks via different boxes.
- Organize factory functions for complex object creation without polluting module scope.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Picobox is a lightweight dependency injection framework that manages object creation and scoping through explicit box-based registration and retrieval, with support for both values and factories.
Yes, if you want a pragmatic, lightweight DI solution without external dependencies. The zero-dependency design, thread-safety, and explicit injection model make it suitable for small to medium projects. However, the aging maintenance status means you should verify compatibility with your target Python version and assess whether the lack of recent updates aligns with your project's stability requirements.
Install
picobox on PyPI
pip
pip install picoboxuv
uv add picoboxpoetry
poetry add picoboxInstalling picobox
Before you install
Installation is frictionless—the package is pure Python with zero runtime dependencies and ships as a wheel. The codebase is lightweight (~500 LOC) and well-typed. Maintenance is aging: the last release was in November 2023, though the repository remains active.
License in practice
Licensed under MIT (permissive), so you can use, modify, and distribute picobox freely in commercial and open-source projects with minimal restrictions.
Quickstart
import picobox
box = picobox.Box()
box.put("key", "value")
with picobox.push(box):
@picobox.pass_("key")
def my_func(val):
return val
result = my_func()
Requires Python 3.8 or later.
Verify before relying
- Whether the aging maintenance status affects stability or compatibility with newer Python versions.
- Real-world performance characteristics under high-concurrency workloads despite thread-safety claims.
- Adoption patterns and ecosystem maturity relative to other DI frameworks in Python.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 998 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 310,283/month — #7,747 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: picobox-4.0.0-py3-none-any.whl
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
dependency-injectorDependency Injector is a dependency injection…
permissive · top 5,000 on PyPI
wireupWireup is a type-driven dependency injection…
permissive · top 15,000 on PyPI
dependenciesImplements constructor injection for dependency…
permissive · top 15,000 on PyPI
in-n-outLightweight dependency injection framework…
permissive · top 15,000 on PyPI
injectorInjector is a Python dependency injection…
permissive · top 5,000 on PyPI
slackA dependency injection container that registers…
permissive · top 15,000 on PyPI
rodiRodi is a dependency injection container for…
permissive · top 15,000 on PyPI
lagomLagom is a lightweight dependency injection…
permissive · top 15,000 on PyPI
punqPunq is a dependency injection container for…
unclear · top 15,000 on PyPI
gin-configGin provides a lightweight configuration…
permissive · top 15,000 on PyPI