skillfed

picobox

Dependency injection framework designed with Python in mind.

picobox v4.0.0 310.3K downloads/30d#7,747 on PyPI51
Permissive license AGING released

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 picobox

uv

uv add picobox

poetry

poetry add picobox

Installing 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

Intended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Libraries

Tags

dependency injection frameworkservice locator patternobject factory managementscope management singletoninversion of control containerthread-safe dependency resolutionlightweight DI container
dependency-injectioninversion-of-controlzero-dependencies

More Libraries packages