Skip to main content

trevis

Project description

Trevis

Easily visualize recursive functions in the console.

from trevis import recursion

@recursion
def fib(n: int) -> int:
    if n < 2: return n
    return fib(n - 1) + fib(n - 2)

fib(4)
# output
fib(4)  3
├╴fib(3)  2
 ├╴fib(2)  1
  ├╴fib(1)  1
  └╴fib(0)  0
 └╴fib(1)  1
└╴fib(2)  1
  ├╴fib(1)  1
  └╴fib(0)  0

Features

  • 🕹️ Interactive mode: Review each function execution interactively, advancing to the next step by pressing Enter. This mode enhances comprehension and debugging by providing a clear visual representation of each step. Enable with recursion(interactive=True).
  • 🌈 Syntax highlighting (upcoming): Enable syntax highlighting in the tree for improved readability. Coming in a future version.
  • 🎲 Non-deterministic function visualization (upcoming): Visualize of all possible execution paths for non-deterministic functions. Coming in a future version.

Installation

Ensure you have Python 3.6 or higher, then install Trevis using pip:

pip install trevis

Contribution

Contributions are welcome! Feel free to submit an issue or pull request.

License

Trevis is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trevis-0.0.1.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distribution

trevis-0.0.1-py3-none-any.whl (3.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page