Re: How to translate python into C
Thanks Szabolcs and Laurence, it's not the crash of python but the crash of cygwin. We can locate the line number but when we submit the crash to cygwin's mail list, they told us they don't speak python. So I'm just trying to re-produce the crash in C. Regards, Johnny -- http://mail.python.org/mailman/listinfo/python-list
Re: How to translate python into C
Il 2005-10-28, Johnny Lee <[EMAIL PROTECTED]> ha scritto: > Thanks, Szabolcs. In fact, I want to reproduce a crush on cygwin. I > used a session of python code to produce the crush, and want to > translate it into C and reproduce it. Is the tools provided by you help > with these issues? Of coz, I'll try them first. :) Do you mean "crash" ? Take a look at this: http://pycrash.sourceforge.net -- Lawrence http://www.oluyede.org/blog -- http://mail.python.org/mailman/listinfo/python-list
Re: How to translate python into C
python script crashed and you want to debug it? if no trace back provided with the line number where the exception raised, then the crash caused by an extension module (most likely written in C), i don't know howto debug it, but at least you can find the place where the crash occures by adding lots of print statements with debug information. i don't think compiling to c would make it easier. there are python debuggers but i've never used one (these can only debug python scripts not the binary extension modules). pdb builtin module: http://docs.python.org/lib/module-pdb.html nice debugger with gui: http://www.digitalpeers.com/pythondebugger/ -- http://mail.python.org/mailman/listinfo/python-list
Re: How to translate python into C
Thanks for your tips Niemann:) Regards, Johnny -- http://mail.python.org/mailman/listinfo/python-list
Re: How to translate python into C
Johnny Lee wrote: > Hi, >First, I want to know whether the python interpreter translate the > code directly into machine code, or translate it into C then into > machine code? Neither this nor that. The interpreter first compiles the code into python 'byte code' - something similar to machine code, but not it is not targeted at the CPU of your system, but for a portable virtual machine. This virtual machine will then execute the byte code, just like a CPU would execute machine code. >Second, if the codes are translated directly into machine codes, how > can I translate the codes into C COMPLETELY the same? if the codes are > translated first into C, where can I get the C source? You may have a look at PyPy. I do not know what it exactly can do, but this might be interesting for you: http://codespeak.net/pypy/dist/pypy/doc/faq.html#how-do-i-compile-my-own-programs -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: How to translate python into C
Szabolcs Nagy wrote: > python creates bytecode (like java classes) > > > you cannot translate python directly to c or machine code, but there > are some projects you probably want to look into > > > Pypy is a python implemetation in python and it can be used to > translate a python scrip to c or llvm code. (large project, work in > progress) > http://codespeak.net/pypy/dist/pypy/doc/news.html > > > Shedskin translates python code to c++ (not all language features > supported) > http://shed-skin.blogspot.com/ > > > Pyrex is a nice language where you can use python and c like code and > it translates into c code. (it is useful for creating fast python > extension modules or a python wrapper around an existing c library) > http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/ Thanks, Szabolcs. In fact, I want to reproduce a crush on cygwin. I used a session of python code to produce the crush, and want to translate it into C and reproduce it. Is the tools provided by you help with these issues? Of coz, I'll try them first. :) Regards, Johnny -- http://mail.python.org/mailman/listinfo/python-list
Re: How to translate python into C
python creates bytecode (like java classes) you cannot translate python directly to c or machine code, but there are some projects you probably want to look into Pypy is a python implemetation in python and it can be used to translate a python scrip to c or llvm code. (large project, work in progress) http://codespeak.net/pypy/dist/pypy/doc/news.html Shedskin translates python code to c++ (not all language features supported) http://shed-skin.blogspot.com/ Pyrex is a nice language where you can use python and c like code and it translates into c code. (it is useful for creating fast python extension modules or a python wrapper around an existing c library) http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/ -- http://mail.python.org/mailman/listinfo/python-list