xmod
🌱 Turn any object into a module 🌱
What it is and what it does
xmod is a lightweight library that lets you give a module the behavior of a callable or container object. Normally, modules are static namespaces; xmod wraps a module so it can respond to function calls, indexing, or other object protocols. This is useful for single-purpose modules where you want to avoid boilerplate and instead call or index the module directly.
The package has no runtime dependencies and works with modern Python versions (3.10–3.14). It's maintained actively with no known vulnerabilities. The core use case is simplifying APIs of modules that "just do one thing" by letting them behave like the objects they export.
Use it for:
- Make a module callable so the module itself can be invoked as a function without intermediate imports.
- Wrap a module around a list or dict to support indexing and mutation directly on the module.
- Reduce import boilerplate in libraries where the module itself is the primary interface.
- Create a module that mimics a built-in type's interface for a more intuitive API.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Lets a module behave like a callable object or container by wrapping it with special methods, eliminating redundant import patterns.
Yes, if you want to simplify module APIs or reduce import boilerplate in single-purpose modules. The package is lightweight, actively maintained, permissively licensed, and carries no security vulnerabilities. Install friction is minimal. It's a niche tool, but well-suited to its specific use case.
Install
xmod on PyPI
pip
pip install xmoduv
uv add xmodpoetry
poetry add xmodInstalling xmod
Before you install
Low install friction with no runtime dependencies. Active maintenance with a recent release 97 days ago and current Python version support (3.10–3.14).
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely with minimal restrictions.
Quickstart
pip install xmod
import xmod
@xmod
def a_function():
return 'result'
# Module is now callable
print(a_function()) # 'result'
Requires Python 3.10 or later.
Verify before relying
- Whether the decorator approach preserves standard module attributes like __all__ and __doc__.
- Performance overhead of the module wrapping mechanism for frequently-accessed modules.
- Compatibility with module introspection tools and import hooks.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 97 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 4,908,921/month — #2,200 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: xmod-1.10.0-py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
wireropeWraps Python callables (functions and methods)…
permissive · top 5,000 on PyPI
zope.hookablezope.hookable provides a mechanism to create…
unclear · top 5,000 on PyPI
lazy-importDefers module loading and ImportErrors until a…
copyleft · top 15,000 on PyPI
publicationPublication hides private implementation…
permissive · top 5,000 on PyPI
threadedProvides decorators to wrap functions for…
permissive · top 15,000 on PyPI
python-utilsA collection of fully-typed utility functions…
permissive · top 5,000 on PyPI
pytest-lazy-fixturesAllows you to reference pytest fixtures…
permissive · top 5,000 on PyPI
decopatchDecopatch simplifies writing decorators in…
permissive · top 5,000 on PyPI
mixed-methodsProvides a decorator that lets a single method…
permissive · top 15,000 on PyPI
wraptwrapt provides a Python module for building…
permissive · top 100 on PyPI