Registry / serialization / xmod
library1.10.0pypypi✓ verified 25d ago

Xmod is a tiny Python library designed to transform any Python object into a module. This allows for modules to be callable, indexable, or to expose an object's methods and properties directly, reducing boilerplate code. It is currently at version 1.9.0 (released February 3, 2026) and maintains an active development status with frequent minor updates and dependency bumps.

pip install xmod
INSTALL
IMPORT
SIG · XMOD
X
xmod
serializationpythonv1.10.0
Install
1.5s avg
Import
11ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.10.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.012s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.006s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

xmod
import xmod

The most common usage is to decorate a function within a module to make the module itself callable. This example demonstrates making the module 'your_module' callable, returning a greeting.

# In your_module.py import xmod @xmod def greet(): return 'Hello from your_module!' # To test in another script or interpreter: # import your_module # print(your_module()) # Expected output: Hello from your_module!
Debug
Known issues
gotchaWhen explicitly providing the `name` argument to `xmod()`, it should almost always be set to `__name__`. Using a different string can lead to unexpected module aliasing or inconsistent behavior within `sys.modules`.
fix
For typical module extension, ensure `xmod(..., name=__name__)` is used. Only deviate if you have an advanced use case requiring specific `sys.modules` manipulation.
affects: All versions
gotchaCombining `xmod` with `functools.partial` can sometimes lead to unexpected behavior. Since version `1.3.2`, `xmod` will raise a clear exception if `functools.partial` is used in a way it doesn't support, to prevent silent failures.
fix
If an exception related to `functools.partial` is raised, adjust your approach as indicated by the error message. Consider alternative partial application techniques or consult `xmod`'s documentation for compatible patterns.
affects: All versions (explicit error in >=1.3.2)
gotchaUsing `xmod(..., full=True)` extends the module with *all* members of the extension object, which might unintentionally overwrite existing module attributes. Additionally, `xmod(..., mutable=True)` allows runtime modification of the module's attributes via the `xmod` proxy, potentially introducing hard-to-debug state changes.
fix
Be selective about attribute exposure; prefer `full=False` and explicitly expose only what's necessary. Understand the implications of mutable module state before setting `mutable=True` and favor immutable extensions where possible.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'xmod'
The `xmod` library has not been installed in the current Python environment.
fix
pip install xmod
TypeError: 'module' object is not callable
The `xmod` module was imported directly (e.g., `import xmod`) and then incorrectly called as a function (e.g., `xmod(my_object)`) instead of its `xmod` function (e.g., `xmod.xmod(my_object)`).
fix
Use `from xmod import xmod` to import the function directly, or call it as `xmod.xmod(my_object)` if you only imported `xmod`.
AttributeError: module '...' has no attribute '...'
An attribute or method was accessed on an `xmod`-generated module that does not exist on the original object it wraps.
fix
Ensure the attribute or method exists on the object passed to `xmod.xmod()`, or check for typos when accessing it through the `xmod`-generated module.
TypeError: 'module' object is not callable
An `xmod`-generated module instance was called directly (e.g., `my_module()`), but the underlying object it wraps does not define a `__call__` method, making the module instance non-callable.
fix
Only call the `xmod`-generated module directly if the object it wraps is callable (has a `__call__` method). Otherwise, access its attributes or methods, e.g., `my_module.some_method()`.
Upgrade
Version history
1.10.0latest on PyPI · released May 9, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
25 hits · last 30 days
node
20
OpenAI (training)
1
Resources
xmod — pip install xmod · libregistry