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 .

## Installation

Install from PyPI:
pip install ASTpytcl

Metadata

Release files for ASTpytcl 0.1.2

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.2
File Size Uploaded Provenance Actions
astpytcl-0.1.2.tar.gz 17.1 kB Without provenance Details for astpytcl-0.1.2.tar.gz

Built distribution (wheel)

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

Total release size: 34.8 kB

Release files / astpytcl-0.1.2.tar.gz

Download URL astpytcl-0.1.2.tar.gz
Size 17.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a385a6b877ea487816d376e82548642d419f3df70c99145e0507c0e7e219d4b2
BLAKE2b-256 checksum
How to use checksums
a4536f1d2765ce28e737c9194138fcaf8a8328090c8b7067b335217bcb8e3d3b
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.2-py3-none-any.whl

Download URL astpytcl-0.1.2-py3-none-any.whl
Size 17.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4f110705e6bef0d7d9d42e091ed83945e3e9d09b54a9fa00be1fa029ca659f20
BLAKE2b-256 checksum
How to use checksums
dd7dfef99ef2a1f0fb1f8e97502c9e7c3d1019ff13dbe81e0a7c28c5fda10751
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.2

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.2 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