Registry / data / glom
library25.12.0pypypi✓ verified 26d ago

glom is a declarative object transformer and formatter for Python, designed to simplify working with nested data structures. It provides path-based access, powerful data transformation using Pythonic specifications, meaningful error messages, and built-in debugging features. The library follows a CalVer versioning scheme (YY.MM.MICRO) and is actively maintained, with version 25.12.0 being a recent release that includes maintenance updates and test fixes for newer Python versions.

pip install glom
INSTALL
IMPORT
SIG · GLOM
G
glom
datapythonv25.12.0
Install
1.8s avg
Import
213ms
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v25.12.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.224s · 20.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.8s · import 0.202s · 21MB
19MB installed
● package 19MB
Code
Verified usage

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

glom
from glom import glom
T
from glom import T
T is a specifier for object-oriented access and method calls.
Coalesce
from glom import Coalesce
Coalesce provides default values for potentially missing or error-raising paths, similar to SQL's COALESCE.
Invoke
from glom import Invoke
from glom import Call
The 'Call' specifier is deprecated in favor of 'Invoke' since glom 19.10.0, which offers a fuller-featured API for invoking callables.
Path
from glom import Path
Explicitly using Path can avoid ambiguities, especially with wildcard characters.
S
from glom import S
S provides access to the glom scope for additional state management during transformations.

This quickstart demonstrates basic deep access to nested data, transformation into a new dictionary structure, and using the `T` specifier for iterating and extracting specific fields from a list of dictionaries.

from glom import glom, T data = { 'user': { 'profile': { 'name': 'Alice', 'email': 'alice@example.com' }, 'preferences': { 'theme': 'dark' } }, 'messages': [ {'id': 1, 'text': 'Hello'}, {'id': 2, 'text': 'World'} ] } # Extract a deeply nested value user_name = glom(data, 'user.profile.name') print(f"User Name: {user_name}") # Transform data to a new structure user_summary_spec = { 'name': 'user.profile.name', 'contact_email': 'user.profile.email', 'first_message': ('messages.0.text', str.upper) } user_summary = glom(data, user_summary_spec) print(f"User Summary: {user_summary}") # Using T for more complex access or method calls message_ids = glom(data, ('messages', [T['id']])) print(f"Message IDs: {message_ids}")
glom --version
Debug
Known issues
breakingThe `*` and `**` wildcard behavior for path access became enabled by default in glom 23.1.0. This can break existing specs that used these characters as literal keys.
fix
If you experience issues, you can temporarily revert the behavior by setting `glom.core.PATH_STAR = False`. The recommended fix is to explicitly use the `Path` specifier, e.g., `Path('a', '*')` instead of `'a.*'`.
affects: >=23.1.0
deprecatedThe `Call` specifier is deprecated in favor of the more comprehensive `Invoke` specifier, introduced in glom 19.10.0. `Invoke` offers a richer API for invoking callables within your specs.
fix
Replace `Call` with `Invoke` in your specs. For calling methods on the target, consider using the `T` object instead.
affects: >=19.10.0
gotchaNot all internal components of the `glom` package are part of its public API. Functionality not explicitly documented in the top-level `glom` package or its official documentation may change or disappear without notice.
fix
Rely only on documented `glom` functions, classes, and specifiers. If you find undocumented functionality that seems useful, consider filing an issue or pull request.
affects: All
gotchaIf `glom()` is called without `default` and `skip_exc` parameters, it will raise exceptions on path access failures (e.g., `PathAccessError` for missing keys/attributes).
fix
Use the `Coalesce` specifier or the `default` and `skip_exc` kwargs in the `glom()` function to gracefully handle missing data or potential errors. `Coalesce` catches exceptions internally and proceeds to the next spec.
affects: All
breakingOfficial support for Python 2 and Python 3.6 was dropped in glom 23.3.0, and pre-Python 3.7 syntax was removed in 24.11.0.
fix
Ensure your project runs on Python 3.7 or newer to use glom versions 23.3.0 and above.
affects: >=23.3.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'glom'
The 'glom' library is not installed in your Python environment.
fix
Install the glom library using pip: `pip install glom`
glom.core.PathAccessError: could not access 'key_name', part X of Path('path', 'to', 'key_name'), got error: KeyError('key_name')
This error occurs when the specified path or a part of it (e.g., a dictionary key or an object attribute) does not exist in the target data structure at the expected level.
fix
Check your target data to ensure the path in your glom spec matches the actual structure. You can use `glom.Coalesce` or the `default` argument in `glom()` to provide fallback values or handle missing paths gracefully. For example: `glom(target, 'a.b.c', default=None)` or `glom(target, Coalesce('a.b.c', 'a.b.fallback_c', default='default_value'))`.
glom.core.CoalesceError: no valid values found. Tried (spec1, spec2) and got (PathAccessError, PathAccessError)
This error is raised by the `Coalesce` specifier when none of its subspecs successfully produce a value (i.e., they all either result in `glom.SKIP` or an exception that `Coalesce` is configured to handle), and no `default` value is provided to `Coalesce` itself.
fix
Ensure at least one subspec in `Coalesce` is expected to match your data, or provide a `default` argument to `Coalesce` to define a value to return if all subspecs fail. Example: `glom(target, Coalesce('key1', 'key2', default='fallback_value'))`.
glom.core.PathAssignError: could not assign X on object at Path(...), got error: IndexError(...)
This error occurs during an assignment operation (using `assign()` or the `Assign` specifier) if you attempt to assign to an invalid or out-of-range position within a list or other mutable sequence, or if the path leads to an immutable object or a read-only property.
fix
Verify that the path and index you are trying to assign to are valid and within the bounds of mutable collections. If you need to create missing intermediate data structures during assignment, use the `missing` argument in `assign()` or `Assign`. Example: `assign(target, 'a.b.c', value, missing=dict)` will create dictionaries for 'a' and 'b' if they don't exist.
Upgrade
Version history
25.12.0latest on PyPI · released Dec 29, 2025
Audit
Dependencies
tomloptionalRequired for TOML support in the CLI for Python versions older than 3.11.
Agent activity
7 hits · last 30 days
node
6
Resources
glom — pip install glom · libregistry