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

Other Useful Business Software
Gen AI apps are built with MongoDB Atlas Icon
Gen AI apps are built with MongoDB Atlas

The database for AI-powered applications.

MongoDB Atlas is the developer-friendly database used to build, scale, and run gen AI and LLM-powered apps—without needing a separate vector database. Atlas offers built-in vector search, global availability across 115+ regions, and flexible document modeling. Start building AI apps faster, all in one place.
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