dm-tree
Tree is a library for working with nested data structures.
Decision gist · record as of 2026-08-14
Yes. dm-tree is actively maintained, has no security vulnerabilities, carries a permissive Apache 2.0 license, and solves a genuine problem in working with nested structures. The medium install friction (compiled wheels) is well-mitigated by broad platform coverage and modern Python support. Install it if your code regularly manipulates nested dicts, lists, or mixed hierarchies—especially in machine learning or data processing contexts.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later; installation pulls in absl-py, attrs, numpy, and wrapt as runtime dependencies.
- Medium install friction due to compiled C++ components requiring platform-specific wheels; however, wheels are available for modern Python versions (3.10–3.14) across macOS, Linux (x86_64 and aarch64), and Windows, and the package is actively maintained with a recent release.
License · maintenance · safety
Apache 2.0 (permissive) — Licensed under Apache 2.0 (permissive), allowing free use, modification, and distribution in both open-source and commercial projects with minimal restrictions.
last release 2026-03-31 (136 days) · last repo commit 2026-08-10 · 1,022 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 5,699,060 downloads/mo, #2,050 on PyPI
Alternatives
Verify before relying
pip install dm-tree
import tree
structure = [[1], [[[2, 3]]], [4]]
flat = tree.flatten(structure) # [1, 2, 3, 4]
mapped = tree.map_structure(lambda v: v**2, structure) # [[1], [[[4, 9]]], [16]]- Whether the C++ backend provides measurable performance gains for typical use cases versus pure Python alternatives.
- API stability guarantees or backward-compatibility policy given the Beta development status.
What it is and what it does
dm-tree is a library for manipulating nested data structures—dictionaries, lists, tuples, and their combinations—by applying operations uniformly to leaf values while preserving the overall container structure. It generalizes Python's built-in `map` function from flat sequences to arbitrarily nested hierarchies. The core operations are `flatten` (convert a nested structure to a flat list), `map_structure` (apply a function to each leaf), and traversal utilities. The implementation is backed by optimized C++ code designed for performance-critical applications like machine learning pipelines that process large nested tensors or parameter trees.
The package depends on absl-py, attrs, numpy, and wrapt, and targets modern Python (3.10+). It is actively maintained, with recent releases and no known security vulnerabilities. The library is particularly useful in machine learning frameworks where nested structures of tensors or parameters are common, though it applies to any domain working with complex hierarchical data.
Use it for
- Flatten nested parameter dictionaries in machine learning models for batch processing or serialization.
- Apply transformations uniformly across all leaves of a nested tensor structure while preserving hierarchy.
- Traverse and validate deeply nested configuration or data structures in data pipelines.
- Convert between nested and flat representations when interfacing with APIs that expect one or the other.
- Implement recursive operations on tree-like data without manual recursion boilerplate.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
dm-tree is actively maintained, has no security vulnerabilities, carries a permissive Apache 2.0 license, and solves a genuine problem in working with nested structures. The medium install friction (compiled wheels) is well-mitigated by broad platform coverage and modern Python support. Install it if your code regularly manipulates nested dicts, lists, or mixed hierarchies—especially in machine learning or data processing contexts.
Install
dm-tree on PyPI
Before you install
Medium install friction due to compiled C++ components requiring platform-specific wheels; however, wheels are available for modern Python versions (3.10–3.14) across macOS, Linux (x86_64 and aarch64), and Windows, and the package is actively maintained with a recent release.
Requires Python 3.10 or later; installation pulls in absl-py, attrs, numpy, and wrapt as runtime dependencies.
License in practice
Licensed under Apache 2.0 (permissive), allowing free use, modification, and distribution in both open-source and commercial projects with minimal restrictions.
Quickstart
pip install dm-tree
import tree
structure = [[1], [[[2, 3]]], [4]]
flat = tree.flatten(structure) # [1, 2, 3, 4]
mapped = tree.map_structure(lambda v: v**2, structure) # [[1], [[[4, 9]]], [16]]
Verify before relying
- Whether the C++ backend provides measurable performance gains for typical use cases versus pure Python alternatives.
- API stability guarantees or backward-compatibility policy given the Beta development status.
Package facts
| License | Apache 2.0 permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Medium. Platform-specific wheel |
| Runtime dependencies | 4 packagesabsl-pyattrsnumpywrapt |
| Maintenance | Actively maintained 136 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 5,699,060 / month, #2,050 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaIntended Audience :: DevelopersIntended Audience :: Science/ResearchLicense :: OSI Approved :: Apache Software LicenseProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Scientific/Engineering :: MathematicsTopic :: Software Development :: Libraries |
Evidence: dm_tree-0.1.10-cp310-cp310-macosx_10_9_universal2.whl; dm_tree-0.1.10-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; dm_tree-0.1.10-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; dm_tree-0.1.10-cp310-cp310-win_amd64.whl; dm_tree-0.1.10-cp311-cp311-macosx_10_9_universal2.whl; dm_tree-0.1.10-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; dm_tree-0.1.10-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; dm_tree-0.1.10-cp311-cp311-win_amd64.whl; dm_tree-0.1.10-cp312-cp312-macosx_10_13_universal2.whl; dm_tree-0.1.10-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; dm_tree-0.1.10-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; dm_tree-0.1.10-cp312-cp312-win_amd64.whl; dm_tree-0.1.10-cp313-cp313-macosx_10_13_universal2.whl; dm_tree-0.1.10-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; dm_tree-0.1.10-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; dm_tree-0.1.10-cp313-cp313t-macosx_10_13_universal2.whl; dm_tree-0.1.10-cp313-cp313t-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; dm_tree-0.1.10-cp313-cp313t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; dm_tree-0.1.10-cp313-cp313-win_amd64.whl; dm_tree-0.1.10-cp314-cp314-macosx_10_15_universal2.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “nested data structure traversal”
- dm-treeProvides utilities for working with nested data…
- dictorDictor provides a simplified interface for navigating and extracting…
- optreeOpTree provides optimized utilities for flattening, unflattening, and…
Give your agent the search over MCP, or paste the wish link into any chat.
More Libraries packages
urllib3 is an HTTP client library that provides thread-safe connection pooling, SSL/TLS verification, multipart file uploads, request retries, compression support, and proxy handling for Python applications.
Requests is a Python HTTP library that simplifies sending HTTP/1.1 requests with automatic handling of headers, authentication, cookies, and response parsing.
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
Provides parsing, arithmetic, and recurrence rule computation for dates and times, with timezone support and iCalendar RFC compliance.
Install it if you need to parse flexible date strings, compute relative dates, handle timezones, or work with recurrence rules—it's the de facto choice for these tasks.
Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
See also optree · pathable · json-normalize · banal · flatdict · llist · json-flatten · treelib · plucky · glom