Maurice LING wrote:
Terry Reedy wrote:

"Maurice LING" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]

Say I code my stuffs in Jython (importing java libraries) in a file "text.py"



Just to be clear, Jython is not a separate langague that you code *in*, but a separate implementation that you may slightly differently code *for*.


Yes, I do get this point rightly. Jython is just an implementation of Python virtual machine using Java. I do note that there are some differences, such as, Jython can only handle pure python modules. However, I'm not a language expert to differentiate language differences between these 2 implementations of Python, as in Jython and CPython. If someone care to enlighten, it will be my pleasure to consult. TIA.

That's not strictly correct. The Python virtual machine isn;t implemented at all in Jython, instead the JVM is used as the compilation target.


... Will there be any issues when I try to import text.py into CPython?



If text.py is written in an appropriate version of Python, it itself will cause no problem. Hoqwever, when it imports javacode files, as opposed to CPython bytecode files, CPython will choke.


In my example, the file "text.py" is coded in Jython, importing Java libraries. I do get that I cannot import Java jar files directly into CPython. What I do not get is that what is so special about Jython that it can "fool" CPython into using Java libraries... or is that there will always be a need for Java virtual machine and Python virtual machine when I use Java libraries in Jython... and importing Jython coded files into CPython....

Jython is pretty much a Python interpreter that compiles Python into JVM bytecodes. Consequently the amount of "trickery" involved is rather less, though clearly there is some (automated conversion b etween Java and Pythin data types where appropriate, and automated signature-based selection of the appropriate Java method being the two most obvious).

regards
 Steve
--
Steve Holden        +1 703 861 4237  +1 800 494 3119
Holden Web LLC             http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/

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

Reply via email to