Pyrex gets a perfect score.

Rick Ratzel rlratzel at siliconmetrics.com
Sat Apr 3 15:10:36 EST 2004


Kyler Laird <Kyler at news.Lairds.org> wrote in message news:<qrruj1-n75.ln1 at snout.lairds.org>...

> The description "Elmer is not a Python-to-C or Python-to-Tcl
> translator" makes me think that it's not appropriate for what I need
> right now - the ability to submit only C code.

   Thats a good point.  In that case, you would use the "-frozen" flag
for Elmer, which uses freeze.py (if available on your system) to
freeze the Python sources into C strings, which are compiled into your
executable/archive.  I emphasized that it is not a translator since
the Python interpreter is still required in all cases.  While the
Elmer-generated C code is readable, the C files consisting of strings
of Python op codes that freeze generates are not...so that may be a
problem if you have to deliver readable code.  I've never had that
problem since I only deliver .a files.

   I once delivered a Python module to a C user (who has no working
knowledge of Python...a similar sounding situation to what you had, I
think) by using "Elmer -frozen" and combining the frozen C code,
Elmer-generated C code, and Python library all into a single archive. 
They simply #included the generated header and linked in the archive
and were off and running...they didn't know they were using Python
until I told them...well, they may have been clued in by the fact that
I could deliver a platform-independent and easy-to-maintain module in
record time ;)

> It does look like it would be useful for later work though.  I think
> it's likely to provide cleaner interfaces than what I was able to
> generate using Pyrex.

   The idea was that a Python developer could share their code with
C/C++ and Tcl users with minimal effort.  The API to their Python
module in C or Tcl resembles, as close as possible, the same API they
use in Python.  Please let me know if you do decide to use it in a
future project as I would love the feedback.  Thanks!



More information about the Python-list mailing list