Python Formatted C Converter (PfCC)

Randall Hopper aa8vb at yahoo.com
Tue Oct 24 10:19:07 EDT 2000


Alex McHale:
 |Hi there,

Hi.

 |  I have started work on a project that I *think* is unique.  If not,
 |someone please send me a URL to such a project's site.
...
 |  First off, let me say; I have a working prototype, with extremely limited
 |functionality.
 |
 |  The project is, as I call it, a Python Formatted C Converter.  What this
 |means, is that it takes a python-style coded C program and converts it into
 |compilable C code. ...

Ouch!  It looks like the flamers hit you first. 8^)

I like the idea myself.  In fact, I've been passively thinking about how
useful something similar might be for a while.  That is: a pure Python to C
translator.  A few quick net searches reveals there's a py2c out there.
Maybe you could use it as a jumping-off point?  (links below)

As you said, it makes sense.  Python is so easy to read and code for.  And
for 95-99% of the code, the speed is academic.  So why not just use Python!?

Python purists would say, develop a C extension for that 1-5% and link it
into your Python interpreter.  That can work.  But if your app must be up
24-7 under heavy load, a little lost garbage here and there is not an
option.  You need to bring in tools like Purify to make sure absolutely
nothing is amiss, and then you're dealing with the C level anyway.

Also, linking Python code into existing apps which "aren't" under Python's
umbrella can be a challenge.  It might be more straightforward to convert
the Python to C, and then just call it.  

Admitedly there are some non-trivial problems (full dynamic typing versus
typed variables, is a full interpreter needed or just basic data type
classes, etc.), many of which I'm sure I haven't thought of, but the
concept sounds interesting at least!

Good luck.

Randall

A few links I just found that might be useful to you:

http://www.python.org/workshops/1996-06/papers/hugunin.IPCIV.html
http://lima.mudlib.org/~rassilon/p2c/  (Broken Pipe right now)
http://www.python.org/sigs/compiler-sig/dev-day-notes.txt
  Py2C (Bill Tutt, Greg Stein)

-- 
Randall Hopper
aa8vb at yahoo.com




More information about the Python-list mailing list