ANN: libtclpy public release

213 views
Skip to first unread message

Aidan Hobson Sayers

unread,
Aug 13, 2014, 9:47:04 PM8/13/14
to
libtclpy is a Tcl extension to effortlessly call Python from inside Tcl.
The intention is to take the good parts of Elmer and tclpython and combine them to let you get going as fast as possible.

Features (or "what sets it apart?")
========
- Easy to compile the library (vs Elmer, tclpython).
- Automatically converts Python lists and dicts to Tcl lists and dicts (vs tclpython).
- Correctly handles both unicode and byte strings (vs tclpython) (Elmer unknown).
- No need for interface files or special code compilation stages (vs Elmer).

Example (or "show me what it can do!")
=======
% package require tclpy # or just `load ./libtclpy.so`
0.3
% py eval {
def uu(n):
n = int(n)
return {"a": 2**n, "b": [n, n*n]}
}
% py call uu 5
a 32 b {5 25}

Roadmap (or "what can't it do (yet)?")
=======
- Compiling on Windows.
- Support for threads.
- Allow Python to call back into Tcl.

Get it (and see a more comprehensive example) at https://github.com/aidanhs/libtclpy
I'm interested in all feedback as libtclpy is still in beta and the design is subject to change. Is it something people might find useful? Is a critical feature missing? Maybe you simply have no reason to need to leave Tcl (notwithstanding the justification below)?

Aidan


--------------


Below is some justification for the existence of libtclpy.

Why would you want to leave Tcl? Why Python?
============================================
Tcl is an easily graspable and capable language with a strong community. Unfortunately the community is smaller than some other languages and library selection suffers as a result, which can mean having to write more code.
Interaction with any 'popular' language would solve this, but I happen to be a fan of Python.

Some concrete examples. In Tcl it can be difficult to:
- interact with the outside world.
- Protocol Buffers. Talked about [1] [2] but nothing publicly available.
- RabbitMq. Talked about [3], all I could find was a 4 year inactive repo [4] [5].
- Thrift. Talked about [6] [7] but nothing publicly available.
- play with computer vision. Talked about [8], you could write the OpenCV tcl bindings yourself if you wanted [9].
- do data analysis and interesting numeric computation. Tcl has recently got VecTcl (reducing this usual big Python selling point) but there's still plenty that isn't so easy.

If you can write 16 lines (I counted) to get basic interaction with a RabbitMQ instance in Tcl, rather than reading up on the protocol and implementing it yourself, you can get straight to the important stuff and fill in the gaps with Tcl later.
This is all about reducing how much code you write - the Tcl wiki has some truly inspired pieces of code, but sometimes the one you want isn't there. Maybe libtclpy (and Python) can help.

If you've never wanted any libraries unavailable in Tcl (I have, obviously), this isn't for you. Tcl has perfectly suitable libraries for most common tasks, and using a single language for an application has definite benefits.

[1] http://wiki.tcl.tk/36472
[2] https://groups.google.com/forum/#!topic/comp.lang.tcl/UA26GfyKT0Y
[3] https://groups.google.com/forum/#!topic/comp.lang.tcl/lz1YVBR2A84
[4] http://rabbitmq.1065348.n5.nabble.com/Python-Client-for-RabbitMQ-AMQP-tp4712p4716.html
[5] http://home.diphi.com/users/jeffr/software/fossil/amqp.fsl/timeline
[6] http://wiki.tcl.tk/36473
[7] https://groups.google.com/forum/#!topic/comp.lang.tcl/GZnIuScux5E
[8] https://groups.google.com/forum/#!topic/comp.lang.tcl/fcvg13i0jTc
[9] http://www.quora.com/Can-anyone-start-off-with-image-processing-in-OpenCV-without-implementing-it-on-some-other-user-friendly-platforms-like-MATLAB-Why-or-why-not

Andrew Shadura

unread,
Aug 27, 2014, 9:55:32 AM8/27/14
to
Hello,

On Thursday, 14 August 2014 03:47:04 UTC+2, Aidan Hobson Sayers wrote:
> libtclpy is a Tcl extension to effortlessly call Python from inside Tcl.
> The intention is to take the good parts of Elmer and tclpython and combine them to let you get going as fast as possible.

Wow, that's cool! I knew tclpython existed, but this thing seems to be even better :)

--
Cheers,
Andrew

Reply all
Reply to author
Forward
0 new messages