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
Simple, Secure Domain Registration Icon
Simple, Secure Domain Registration

Get your domain at wholesale price. Cloudflare offers simple, secure registration with no markups, plus free DNS, CDN, and SSL integration.

Register or renew your domain and pay only what we pay. No markups, hidden fees, or surprise add-ons. Choose from over 400 TLDs (.com, .ai, .dev). Every domain is integrated with Cloudflare's industry-leading DNS, CDN, and free SSL to make your site faster and more secure. Simple, secure, at-cost domain registration.
Sign up for 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