Skip to main content

LittleTree is a library that provides a tree data structure to python, which is both fast and flexible. It can be used to represent file systems, taxonomies and much more.

Features

  • Intuitive basic creation and modification of trees.
  • Efficient implementation of common tree operations and traversals that still work on trees that are more than 10,000 layers deep.
  • Extensible: either subclass from Node or BaseNode.
  • Can be imported / exported to many different formats (nested dict, rows, relations, graphviz, mermaid, newick, networkx).
  • Purely written in Python.

Limitation

  • Each node has at most one parent. (It's a tree not a graph!)

Installing

  • Use pip to install littletree:
$ pip install --upgrade littletree

Usage

A tree can be used in a similar way as a dict:

from littletree import Node

tree = Node(identifier="World")
tree["Asia"] = Node()
tree["Africa"] = Node(data={"surface_area": 30.37e6})
tree["America"] = Node()

# Alternative way of adding a node
tree.add_child(Node(identifier="Europe"))

# Print tree to console
tree.show()

# Show tree as an image
tree.to_pillow().show()

The resulting tree is printed like this:

World
├─ Asia
├─ Africa
├─ America
└─ Europe

If Pillow and graphviz are installed, it will also display the following image:

world

See tutorial for more information.

See further: Pypi | Github | Issues | Documentation

Metadata

Release files for littletree 0.9.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for littletree 0.9.1
File Interpreter ABI Platform Actions
littletree-0.9.1-py3-none-any.whl Python 3 none any Details for littletree-0.9.1-py3-none-any.whl

Release files / littletree-0.9.1-py3-none-any.whl

Download URL littletree-0.9.1-py3-none-any.whl
Size 24.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
03ab9f57e39dcf773562271e94c3a4cc020507d6c51db91dcf10d23fbd00e65d
BLAKE2b-256 checksum
How to use checksums
60ef93570a0c158d11cc75650ee3958284fbd94fddd587ffc5c6f739e65867d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.0

Security for littletree 0.9.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page