Re: Python2CPP ?

2006-04-13 Thread jpierce

Diez B. Roggisch wrote:
  1) Curiosity. I would like to see how well the translation goes.

 If there is something that works, it will look awful to the eye.
 Code-generators are generally not very idiomatic - they mapping is to
 localized to e.g. factorize out a more complex loop to something a
 generator might to much better.

 I suggest you take a look at pyrex, a python-like language that bridges
 python and C by generating C.

  2) Efficiency. It is alot quicker to code something in Python. If I can
 write it in Python and auto-convert it to C++. I would save time
 coding.

 Then let it run in python.

  3) Education. I would learn more about Python, C++, their similarities and
  differences.

 I also doubt that. digging into generated, non-idiomatic code won't do much
 for you to grasp what is behind Python or C++ as well. Think e.g. of
 templating, a major feature in C++ that certainly won't be utilized by a
 code-generator that does everything based on python C-structures and their
 C-API.
 
 Regards,
 
 Diez

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python2CPP ?

2006-04-13 Thread jpierce

Diez B. Roggisch wrote:
  1) Curiosity. I would like to see how well the translation goes.

 If there is something that works, it will look awful to the eye.
 Code-generators are generally not very idiomatic - they mapping is to
 localized to e.g. factorize out a more complex loop to something a
 generator might to much better.

 I suggest you take a look at pyrex, a python-like language that bridges
 python and C by generating C.

  2) Efficiency. It is alot quicker to code something in Python. If I can
 write it in Python and auto-convert it to C++. I would save time
 coding.

 Then let it run in python.

  3) Education. I would learn more about Python, C++, their similarities and
  differences.

 I also doubt that. digging into generated, non-idiomatic code won't do much
 for you to grasp what is behind Python or C++ as well. Think e.g. of
 templating, a major feature in C++ that certainly won't be utilized by a
 code-generator that does everything based on python C-structures and their
 C-API.
 
 Regards,
 
 Diez

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python2CPP ?

2006-04-12 Thread Szabolcs Berecz
First of all: why do you want to translate pythont to C++?

Anyway, this has a C back-end:
http://www.pypy.org

Szabi

On 4/12/06, Michael Yanowitz [EMAIL PROTECTED] wrote:
 Hello:

One topic that has always interested me are the Language translators.
 Are there any that convert between Python and C++ or Python and Java?
 I remember seeing one that converts from Python to or from Perl but couldn't
 find it on a quick google search. I did find a Python2C
 http://sourceforge.net/projects/p2c/ and I found:
 http://www.strout.net/python/ai/python2c.py  which are obviously incomplete.
I know there have been many discussions recently regarding C and C++.
 I am (or is it - was?) a C/C++ programmer for over 15 years. Just started
 with Python as we need to write come quick code in script form which can
 be generated and run through an interpreter.
If not could there be a converter from Python to/from Language X and
 from Language X to/from C or C++?
In another thread mentioning a decompiler. Perhaps Python to Assembly
 and Assembly 2 C?

 Thanks in advance:

 --
 http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Python2CPP ?

2006-04-12 Thread Michael Yanowitz
 First of all: why do you want to translate pythont to C++?

 Anyway, this has a C back-end:
 http://www.pypy.org

 Szabi

  Thanks. I want to translate from Python to C++ for a few reasons:
1) Curiosity. I would like to see how well the translation goes.
2) Efficiency. It is alot quicker to code something in Python. If I can
   write it in Python and auto-convert it to C++. I would save time coding.
3) Education. I would learn more about Python, C++, their similarities and
differences.
4) Other. Just want to know how well Language translators work these days. I
have seen
   Fortran2C and Pascal2C translators in the past. Would like to see how
well these
   work with Python.

Thanks in advance:

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python2CPP ?

2006-04-12 Thread Szabolcs Berecz
On 4/12/06, Michael Yanowitz [EMAIL PROTECTED] wrote:
 2) Efficiency. It is alot quicker to code something in Python. If I can
write it in Python and auto-convert it to C++. I would save time coding.

I don't think you will get a more efficient code. The reason is the
extremely dynamic nature of python. Almost everything is done at
runtime. I think one goal of PyPy is to automatically infer the types
of variable, but I don't think they have reached that point, yet. One
project you can consider is the psycho python package which generates
specialized native code at the price of high memory consumption.

 3) Education. I would learn more about Python, C++, their similarities and
 differences.

I don't think so. Higher level languages translated to C are not very
readable (or at least that's what I have seen)

 4) Other. Just want to know how well Language translators work these days. I
 have seen
Fortran2C and Pascal2C translators in the past. Would like to see how
 well these
work with Python.

Than I think PyPy is the way to go. I have heard about another project
with the goal of translating python to high efficiency C++ code but
forgot the url. Anybody?

Szabi
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Python2CPP ?

2006-04-12 Thread Diez B. Roggisch
 1) Curiosity. I would like to see how well the translation goes.

If there is something that works, it will look awful to the eye.
Code-generators are generally not very idiomatic - they mapping is to
localized to e.g. factorize out a more complex loop to something a
generator might to much better.

I suggest you take a look at pyrex, a python-like language that bridges
python and C by generating C.

 2) Efficiency. It is alot quicker to code something in Python. If I can
write it in Python and auto-convert it to C++. I would save time
coding.

Then let it run in python.

 3) Education. I would learn more about Python, C++, their similarities and
 differences.

I also doubt that. digging into generated, non-idiomatic code won't do much
for you to grasp what is behind Python or C++ as well. Think e.g. of
templating, a major feature in C++ that certainly won't be utilized by a
code-generator that does everything based on python C-structures and their
C-API.

Regards,

Diez
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python2CPP ?

2006-04-12 Thread Jay Parlar

On Apr 12, 2006, at 5:13 AM, Michael Yanowitz wrote:


   Thanks. I want to translate from Python to C++ for a few reasons:
 1) Curiosity. I would like to see how well the translation goes.
 2) Efficiency. It is alot quicker to code something in Python. If I can
write it in Python and auto-convert it to C++. I would save time 
 coding.
 3) Education. I would learn more about Python, C++, their similarities 
 and
 differences.
 4) Other. Just want to know how well Language translators work these 
 days. I
 have seen
Fortran2C and Pascal2C translators in the past. Would like to see 
 how
 well these
work with Python.

 Thanks in advance:

You want this: http://shed-skin.blogspot.com/  It can only do a subset 
of Python, but it does generate C++ code, and it can see some big 
speedups.

Jay P.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python2CPP ?

2006-04-12 Thread Ben C
On 2006-04-12, Michael Yanowitz [EMAIL PROTECTED] wrote:
 Hello:

One topic that has always interested me are the Language translators.
 Are there any that convert between Python and C++ or Python and Java?
 I remember seeing one that converts from Python to or from Perl but couldn't
 find it on a quick google search. I did find a Python2C
 http://sourceforge.net/projects/p2c/ and I found:
 http://www.strout.net/python/ai/python2c.py  which are obviously incomplete.
I know there have been many discussions recently regarding C and C++.
 I am (or is it - was?) a C/C++ programmer for over 15 years. Just started
 with Python as we need to write come quick code in script form which can
 be generated and run through an interpreter.
If not could there be a converter from Python to/from Language X and
 from Language X to/from C or C++?

I've heard of an incomplete Python to C++ translator called Shedskin

http://pycode.com/modules/?id=40PHPSESSID=1919541171352770795c2bcee95b46bd

There's also a GNU project afoot for a Python to Scheme translator which
I saw on http://savannah.gnu.org but now cannot find. This would be an
interesting project, I suppose you'd write it in Python, then it could
bootstrap itself into Scheme and C.

Scheme can be translated to C using chicken:

http://www.call-with-current-continuation.org/index.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python2CPP ?

2006-04-12 Thread cfbolz
Hi!

Szabolcs Berecz schrieb:
 On 4/12/06, Michael Yanowitz [EMAIL PROTECTED] wrote:
  2) Efficiency. It is alot quicker to code something in Python. If I can
 write it in Python and auto-convert it to C++. I would save time coding.

 I don't think you will get a more efficient code. The reason is the
 extremely dynamic nature of python. Almost everything is done at
 runtime. I think one goal of PyPy is to automatically infer the types
 of variable, but I don't think they have reached that point, yet. One
 project you can consider is the psycho python package which generates
 specialized native code at the price of high memory consumption.

PyPy can infer the types of variables - but not of any Python program.
Also the C code that is the result is quite a bit more efficient
(currently around a factor of 300 or so), but it works only for a
restricted subset of Python (which is called RPython in PyPy jargon).
PyPy can translate not only to C, but also to LLVM. Backends for
Smalltalk, the CLI and Javascript are being worked on.

  3) Education. I would learn more about Python, C++, their similarities and
  differences.

 I don't think so. Higher level languages translated to C are not very
 readable (or at least that's what I have seen)

The result of a PyPy translation is definitively _not_ readable :-).

  4) Other. Just want to know how well Language translators work these days. I
  have seen
 Fortran2C and Pascal2C translators in the past. Would like to see how
  well these
 work with Python.

 Than I think PyPy is the way to go. I have heard about another project
 with the goal of translating python to high efficiency C++ code but
 forgot the url. Anybody?

It is not the goal of PyPy to be a generally useful Python to C (or to
anything else) translator. The translator is just a side-product of how
PyPy bootstraps its interpreter (which is written in RPython). The
result might be somewhat useable for other stuff too, but it was never
meant to work for a general Python program.

Cheers,

Carl Friedrich Bolz

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python2CPP ?

2006-04-12 Thread Luis M. González
You should check Shed Skin (Python-to-C++ Compiler):

http://shed-skin.blogspot.com/

-- 
http://mail.python.org/mailman/listinfo/python-list