trampoline
Simple and tiny yield-based trampoline implementation.
Decision gist · record as of 2026-08-14
No. The package is abandoned (last release 2018-08-18) and only declares support for Python 3.5, 3.6, 3.7, making it a poor fit for modern Python environments. While the concept is sound and the code is simple, the lack of maintenance means no compatibility fixes for newer Python versions, no bug fixes, and no assurance it will work with current tooling. For new projects, consider implementing a similar pattern yourself; for legacy code already using it, proceed with caution and test thoroughly on your target Python version.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Functions must be rewritten as generators using yield at recursive call sites; existing recursive code cannot be used directly without modification.
- Installation is frictionless—a pure Python wheel with no runtime dependencies.
- However, the package is abandoned; its latest release was 2018-08-18 with no updates since, so it will not receive bug fixes or compatibility patches for newer Python versions.
License · maintenance · safety
MIT (permissive) — MIT license (permissive) places no restrictions on use, modification, or distribution, making it safe to incorporate into commercial or open-source projects.
last release 2018-08-18 (2918 days)
0 known vulnerabilities (OSV.dev, 2026-08-14) · 1,796,619 downloads/mo, #3,550 on PyPI
Alternatives
Verify before relying
from trampoline import trampoline
def factorial(n):
if n <= 1:
return 1
value = yield factorial(n - 1)
return value * n
result = trampoline(factorial(10))
print(result) # 3628800- Whether the package works reliably with Python versions beyond 3.7 (classifiers list only 3.5, 3.6, 3.7).
- Performance characteristics when recursing deeply, given the description mentions memory consumption as a caveat.
What it is and what it does
Trampoline is a minimal yield-based implementation that allows recursive functions to sidestep Python's recursion depth limit by converting them into generators. Instead of calling functions recursively, trampolined functions yield the generator of the next call they want to make; the trampoline function then executes these generators iteratively, effectively simulating unlimited recursion without consuming stack frames.
To use it, you convert a recursive function into a generator by adding yield statements before recursive calls, then wrap the initial call with trampoline(). The package handles return values through yield expressions, preserves exception tracebacks, and supports tail calls via a TailCall exception. It has no external dependencies and consists of roughly 30 lines of core logic, making it lightweight and easy to understand.
Use it for
- Computing factorials or other recursive mathematical functions with large inputs that would normally hit the recursion limit.
- Traversing deeply nested tree or graph structures without stack overflow.
- Implementing tail-recursive algorithms that benefit from constant-memory execution via TailCall.
- Writing recursive methods in classes where subclasses need to extend or override trampolined behavior.
- Processing recursive data structures like nested lists or custom node hierarchies in a single call.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
No.
The package is abandoned (last release 2018-08-18) and only declares support for Python 3.5, 3.6, 3.7, making it a poor fit for modern Python environments. While the concept is sound and the code is simple, the lack of maintenance means no compatibility fixes for newer Python versions, no bug fixes, and no assurance it will work with current tooling. For new projects, consider implementing a similar pattern yourself; for legacy code already using it, proceed with caution and test thoroughly on your target Python version.
Install
trampoline on PyPI
Before you install
Installation is frictionless—a pure Python wheel with no runtime dependencies. However, the package is abandoned; its latest release was 2018-08-18 with no updates since, so it will not receive bug fixes or compatibility patches for newer Python versions.
Functions must be rewritten as generators using yield at recursive call sites; existing recursive code cannot be used directly without modification.
License in practice
MIT license (permissive) places no restrictions on use, modification, or distribution, making it safe to incorporate into commercial or open-source projects.
Quickstart
from trampoline import trampoline
def factorial(n):
if n <= 1:
return 1
value = yield factorial(n - 1)
return value * n
result = trampoline(factorial(10))
print(result) # 3628800
Verify before relying
- Whether the package works reliably with Python versions beyond 3.7 (classifiers list only 3.5, 3.6, 3.7).
- Performance characteristics when recursing deeply, given the description mentions memory consumption as a caveat.
Package facts
| License | MIT permissive |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Abandoned 2,918 days since the last release |
| First released | |
| Downloads | 1,796,619 / month, #3,550 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 3 - AlphaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7 |
Evidence: trampoline-0.1.2-py3-none-any.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 › “recursion depth limit”
- trampolineEnables recursive functions to bypass Python's recursion depth limit…
- ruamel.yamlLoads and dumps YAML 1.2 with round-trip preservation of comments,…
- seedirGenerates ASCII tree diagrams of folder structures with customizable…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also tailer · infinity · allpairspy · tracebackturbo3 · recursive-diff · leval · scantree · async_generator · retrying · ovld