TCLpy Logo

TCLpy 🚀

A Lightweight, Zero-Dependency Tcl-to-Python Compiler & FFI Bridge

Overview

tclpy is a high-performance, open-source Tcl-to-Python bridge and execution engine. Instead of running a string-based interpreter, it compiles Tcl source code directly into native CPython AST nodes, delivering seamless Python interoperability while preserving Tcl's core command semantics.

Installation

Install the package directly from PyPI once released:

pip install ASTpytcl

Or install locally in editable mode for development:

git clone https://github.com/TCLpy/TCLpy.git
cd TCLpy
pip install -e .

Embedding in Python

tclpy provides a clean, top-level Python API allowing you to evaluate Tcl strings and source script files while sharing state via environment dictionaries:

import tclpy

# Shared state environment dictionary
env = {"a": 15, "b": 25}

# Evaluate Tcl expressions directly
tclpy.eval('set product [expr {$a * $b}]', env)
print(env["product"])  # Output: 375

# Source and execute .tcl script files
tclpy.source("script.tcl", env)

Key Features