Tree (dm-tree) is a lightweight Python library developed by Google DeepMind for manipulating nested data structures (also called pytrees). It generalizes Python’s built-in map function to operate over arbitrarily nested collections — including lists, tuples, dicts, and custom container types — while preserving their structure. This makes it particularly useful in machine learning pipelines and JAX-based workflows, where complex parameter trees or hierarchical state representations are common. The library provides efficient operations such as flatten, unflatten, and map_structure, enabling users to apply functions to all leaves of a nested structure seamlessly. Backed by a high-performance C++ core, tree is optimized for large-scale, performance-critical applications.

Features

  • Simple installation via PyPI or GitHub
  • Compatible with frameworks like TensorFlow, JAX, and Sonnet
  • Backed by a C++ implementation for high-speed operations
  • Apply functions recursively to all leaves in nested data structures
  • Preserve the structure of lists, tuples, dicts, and other containers
  • Flatten and unflatten complex structures efficiently

Project Samples

Project Activity

See All Activity >

Categories

Libraries

License

Apache License V2.0

Follow Tree

Tree Web Site

You Might Also Like
MongoDB Atlas runs apps anywhere Icon
MongoDB Atlas runs apps anywhere

Deploy in 115+ regions with the modern database for every enterprise.

MongoDB Atlas gives you the freedom to build and run modern applications anywhere—across AWS, Azure, and Google Cloud. With global availability in over 115 regions, Atlas lets you deploy close to your users, meet compliance needs, and scale with confidence across any geography.
Start Free
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of Tree!

Additional Project Details

Operating Systems

Linux, Mac, Windows

Programming Language

C++, Python

Related Categories

Python Libraries, C++ Libraries

Registered

2025-10-09