Skip to main content

TCLpy Astrolabe Snake Logo

TCLpy 🚀

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

tclpy is a high-performance, open-source Tcl-to-Python bridge and execution engine. Instead of running a string-based interpreter, tclpy compiles Tcl source code directly into native CPython AST nodes (ast.Assign, ast.If, ast.For, ast.Call), delivering seamless Python interoperability while preserving Tcl's core "everything is a string" command semantics. tclpy was inspired by hylang. We want to bring the fun back to coding in TCL.


Key Features

  • AST-Based Compilation: Compiles Tcl control flow, variable bindings, and command calls directly into CPython Abstract Syntax Tree nodes for native execution speed.
  • Direct Python Interop: Import any Python module or standard library package via py::import and invoke functions using Tcl's double-colon notation (math::sqrt, os::listdir).
  • Unified Scope Model: Shares state transparently between Tcl proc definitions, variable namespaces, and Python objects.
  • Tcl-First Presentation: Internal storage leverages high-performance Python objects, while external output marshaling formats collections into traditional space-separated Tcl strings.
  • Zero-Overhead Hybrid Execution: Keeps Tcl managing high-level application state, event loops, and logic, while executing Python object-heavy operations smoothly.
  • Minimalist Design Philosophy: Avoids unnecessary AST bloat by providing py_exec for inline Python edge cases rather than polluting the core grammar.

Recent Features & Capabilities

  • TCP Socket Support: Full support for client connections (socket host port) and background server listeners (socket -server callback port) using multithreading and environment-bound callback execution.
  • Channel & Flush Operations: Interoperable channel management (_open_channels) supporting open, gets, puts, close, and flush across both files and network streams.
  • Extended String Command Suite: Comprehensive implementation of Tcl string subcommands including length, index, range, compare, equal, first, last, match, map, toupper, tolower, trim, replace, and is.

Core Command Set

Category Commands
Variables & Data set, unset, incr
Control Flow if / elseif / else, while, foreach, break, continue
Procedures & Logic proc, return, expr
Collections llength, lindex, lappend
I/O & Output puts, read, gets, open, close, socket, flush
Python Bridge py::import (access Python libraries), py_exec (run inline Python code)

String Operations Quick Reference

Operation Syntax Example Description Result
length string length "Hello" Returns the number of characters. 5
index string index "Tcl" 1 Retrieves the character at a 0-based index. c
range string range "Python" 0 2 Extracts a substring from start to end index. Pyt
compare string compare "abc" "def" Lexicographically compares two strings (-1, 0, 1). -1
equal string equal -nocase "A" "a" Returns 1 if identical, 0 otherwise. 1
first string first "bc" "abcde" Finds first index of a substring. 1
last string last "a" "banana" Finds last index of a substring. 5
match string match "test*" "testing" Performs glob-style wildcard pattern matching. 1
map string map {a 1 b 2} "abab" Replaces substrings based on key-value pairs. 1212
replace string replace "I like Java" 7 10 "Tcl" Replaces a range of characters. "I like Tcl"
tolower string tolower "HELLO" Converts string to lowercase. "hello"
toupper string toupper "hello" Converts string to uppercase. "HELLO"
trim string trim " abc " Strips leading/trailing whitespaces. "abc"
is string is integer -strict "123" Validates character classes. 1

Quickstart & Installation

git clone [https://github.com/TCLpy/TCLpy.git](https://github.com/TCLpy/TCLpy.git)
cd tclpy
pip install -e .

Metadata

Release files for ASTpytcl 0.1.1

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

Source distribution (sdist)

Source distribution for ASTpytcl 0.1.1
File Size Uploaded Provenance Actions
astpytcl-0.1.1.tar.gz 17.1 kB Without provenance Details for astpytcl-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 34.7 kB

Release files / astpytcl-0.1.1.tar.gz

Download URL astpytcl-0.1.1.tar.gz
Size 17.1 kB
Tags Source
SHA-256 checksum
How to use checksums
84263a26a71e1aef63b250e3e767865f2b6e1dfbeafa9bb99f0c52f5fee7715d
BLAKE2b-256 checksum
How to use checksums
98e2460881c029fe4bd38404d8f2e41ac533f13243788d538d90495848c36669
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Release files / astpytcl-0.1.1-py3-none-any.whl

Download URL astpytcl-0.1.1-py3-none-any.whl
Size 17.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d46bde184482d6172c0d9e62870cdae1f44a917bd0120222d61b26688ac82fcc
BLAKE2b-256 checksum
How to use checksums
6a4ebfa44cb1884cbe5c57c94d7534765962aef8e3ee7929f9f0d97284fd55fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Security for ASTpytcl 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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