Advanced (?) compiling, freezing, translating Python

L

luszczek1

Hi,

here's my problem:

- I know it will take me 10 times as long to write a code in C than in
Python
- I need the speed of the C version
- my program cannot depend/require on Python
interpreter/libraries/modules

Is there a way to write Python program that almost looks like (say) C
and then transoform it into C. Transformation should be intelligent -
I don't want dynamic objects with dictionaries of methods. I'm willing
to provide type descriptions so when I say:
myList = [0] * 100

I get in C:
int *myList;
myList = calloc(100, sizeof(int));

I'm aware of projects like Pyrex, Psyco, and Pypy but their scope is
too broad: they are about Python in its entirety and dynamism.
There was also discussion some time back about adding static typing to
Python. This is not what I'm thinking about either.

I gave C as an example, but what I meant was translating Python
into another language with some additional guidance (command-line
optons or "header files"). I believe that Python is rich enough
to express most of semantics of most of languages. For example,
C++ templates are included in Python by default:

In Python:
def sum(aList):
v = 0
for e in aList: v += e

In C++:
template <class T> sum(Vector<T> aList) {...}

In case anybody would care, even primitive data types from C/C++ like
float, short, etc. can be emulated in Python with array module. I don't
see equivalence to C++ reference, value, and pointer semantics, but most
folks can live without it.

Does anything like this exist? Would anybody find it useful?
With compiler module now in standard Python, it seems like an easy job.
Or am I missing something?

Peter


__________________________________________________________________
New! Unlimited Access from the Netscape Internet Service.
Beta test the new Netscape Internet Service for only $1.00 per month until 3/1/04.
Sign up today at http://isp.netscape.com/register
Act now to get a personalized email address!

Netscape. Just the Net You Need.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top