|
View:
New views
14 Messages
—
Rating Filter:
Alert me
|
|
|
Use Python libs or Java libsHi list,
This is probably a common question, but I figured I'd ask again. There is a certain amount of overlap between the Java libraries and Python libraries, so when using Jython, when does one know which to use?
For example, both have os and sys libs, that have similar functionality. How does one decide? Thanks.
------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: Use Python libs or Java libsI am afraid I have some bad news for you. Jython CANNOT use python libraries. Of course there ways that jython could use python libraries . Two come in mind this moment: a) Use a python library that uses pure python with no C/C++ wrappings. I am afraid that is very rare in python libraries b) Use C/C++ wrapped python libraries ported to Java through JNI. Very rare to do or find. So as a general rule you are forced to use in 99% of cases Java libraries with jython, and python libraries with python. Why choose python instead of java libraries ? Well because python libraries are much more "pythonic" thus easier to use and understand. However using jython makes it easy to jump from jython to python as the diffirences between the two languages are minimal. So in the end , jython is a very useful for java developer who want some of the ease of use of python , or for python programmers that want access to myriads of Java libraries out there. If you want to use both , Java and python libraries , then your porgramm should be made in both languages Jython and Python and make a way for the two to communicate with each other.
|
|
|
Re: Use Python libs or Java libsOn 19 May 2009, at 12:57, kilon wrote:
> Jython CANNOT use python libraries. Jython can use libraries written purely in Python. (For example, the pickle machinery works fine.) Many of these ship with the Jython distribution. Jython can't use libraries that call into C. -- N. Nick Rothwell / Cassiel.com Limited www.cassiel.com www.myspace.com/cassieldotcom www.last.fm/music/cassiel www.reverbnation.com/cassiel www.linkedin.com/in/cassiel www.loadbang.net ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: Use Python libs or Java libsJust to be clear here:
Jython can certainly call Python libraries, because Jython is simply an implementation of the Python language for the Java platform. For the 2.5 release, our major focus has been compatibility with the 2.5 version of the Python language and specifically with the CPython reference implementation.
For previous releases, like Jython 2.2, I would suspect most Python 2.2 code would also run fine, it's just now we are trying to run larger, more ambitious code in Python as a community. Consider Django, Twisted, Pylons, or SymPy.
In my experience, most interesting libraries are written in pure Python. Often it's in pure Python to simplify support on Windows, or even for other implementations like ours or IronPython.
Now granted, there are libraries that don't run on Jython. These libraries are written to use the C extension API. The most significant ones I know of are PIL and NumPy. There are also others that optionally use C extensions to increase performance; we should run on them, but perhaps without the desired performance, until we have similar Java extensions in place.
Other libraries use ctypes, which has started to replace the use of the C extension API in most code. The good news is that we will almost certainly have ctypes support in our 2.5.1 release, using work from PyPy and JRuby.
Then there are libraries that rely on specific functionality, like os.fork or advanced signal handling. JRuby has had some progress on the former, and we share development on the underlying jna-posix library, regardless, these are Python libraries that would not be portable to non-Unix systems.
- Jim On Tue, May 19, 2009 at 7:43 AM, Nick Rothwell <nick@...> wrote:
-- Jim Baker jbaker@... ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: Use Python libs or Java libs[kilon]
> I am afraid I have some bad news for you. > > Jython CANNOT use python libraries. That's not true. Of the 375 libraries distributed with jython, 315 are taken directly, unmodified, from cpython. This talk by Jim and Tobias discusses the topic. http://parleys.com/display/PARLEYS/Home#slide=1;talk=30375937;title=Jython > Of course there ways that jython could use python libraries . Two come in > mind this moment: > > a) Use a python library that uses pure python with no C/C++ wrappings. I am > afraid that is very rare in python libraries Actually, it is very common in python libraries. See above. Also see Django, Turbogears, etc. > b) Use C/C++ wrapped python libraries ported to Java through JNI. Very rare > to do or find. This is indeed currently rare, but will become less so when work on the ctypes branch is complete. http://fisheye3.atlassian.com/browse/jython/branches/ctypes-via-rawffi > So as a general rule you are forced to use in 99% of cases Java libraries > with jython, and python libraries with python. That's not true. Jython does make it extremely easy to use java libraries. But most of the time you will find that cpython modules will work straight out of the box on jython; increasing numbers of cpython module providers are making sure that their code runs on jython. Alan. ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: Use Python libs or Java libsWell As far As I have seen , most python libraries that I do use are wrappings of C/C++ libraries .
I saw several discussions here that C/C++ wrapped python libraries cannot be accessed directly. Ok I stand corrected. So then it is my turn to ask questions. 1) Is pySqlite3 ported to jython ? 2) Is pygame ported to jython ? 3) Is wxPython ported to jython ? (SWIG is alright but i find Wx Python , more pythonic ;) ) These three libraries are the MOST important to me. Sorry if I mislead the original poster but I thought that most python libraries were using or interacting with C++ code in one way or anotherto make it hard to port to jython. My bad !!! Another question , how do you make CPython libraries immediately availables in jython , through JNI or other means ? I agree ctypes addition will be very useful for jython as it already is for python. |
|
|
Re: Use Python libs or Java libsKilon,
sqlite3 support is planned for Jython 2.5.1. Leo Soto demonstrated working with it for his Summer of Code project with me last year, but only through a Django backend. I think he ran into some issues, but they're likely surmountable. pygame uses ctypes extensively. It will be a good test case for our implementation of ctypes, again planned for 2.5.1. wxPython support would be very unlikely, given that Swing and SWT provide much better capabilities. Of course we would always welcome someone working on this if it made sense to them.
Your best bet for using C code today is through JNA, which can be directly called from Jython and does not require a separate compilation step, unlike JNI. It's not sufficient for implementing a general foreign function interface, but it's certainly workable for most usages.
- Jim
On Tue, May 19, 2009 at 11:08 AM, kilon <thekilon@...> wrote:
-- Jim Baker jbaker@... ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: Use Python libs or Java libsThanks Jim for replying .
It is great news that sqlite3 is coming to jython. I am sure it will make alot of people happy. Pygame is something I wish to mess out with at some point , seams like an easy way to work with graphics. Swing is all nice and cool , and integrates perfectly with JAVA2D which expands its capabilities . But I always like to keep my options open. I am new with wxPython, and would like to try pyGTK . I cannot comment on wxPython abilities but it seems to me easier to handle than Swing. One more question , how can I connect a python and jython program ? I know that jython follows closely the python syntax or should I say to the letter? So I was wondering if the two could work together without too many steps. Thanks for all the help!!!!
|
|
|
Re: Use Python libs or Java libsWow, it looks like I hit a nerve here.
I guess my primary interest is getting pure Python libraries to work with my Jython implementation. Or is it easier (i.e. less work) to import Java libraries instead?
On Tue, May 19, 2009 at 12:40 PM, kilon <thekilon@...> wrote:
------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
|
|
|
Re: Use Python libs or Java libsOn Tue, May 19, 2009 at 6:35 PM, LoD MoD <lodmod.dod@...> wrote:
> Wow, it looks like I hit a nerve here. > I guess my primary interest is getting pure Python libraries to work with my > Jython implementation. > Or is it easier (i.e. less work) to import Java libraries instead? My personal preference is: a) Use Python libraries if available. Python libraries tend to have a friendlier API than its Java counterpart. The counterpart of this point being: b) Use Java libraries if they are more powerful, either as in having-more-features or in much-faster-and-speed-is-a-concern. But this is my opinion -- take it with a grain of salt. Regards, -- Leo Soto M. http://blog.leosoto.com ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: Use Python libs or Java libs[Roger]
> Speaking of runtime, is there a trick to preventing jython from > caching/printing the full build path on exceptions? We don't want > developer usernames (as part of their build path) showing up on end-user > systems. Assuming that you're willing to wrap your entire program with an exception handler, so that all possible exceptions during the execution of the program are caught by it, the traceback module should contain all you need to extract and reformat traceback information according to your needs. >>> import sys >>> try: ... 1/0 ... except Exception, x: ... a,b,c = sys.exc_info() ... >>> a <type 'exceptions.ZeroDivisionError'> >>> b ZeroDivisionError('integer division or modulo by zero',) >>> c <traceback object at 0x1> >>> import traceback >>> for t in traceback.extract_tb(c): ... print t ... ('<stdin>', 2, '<module>', None) HTH, Alan. ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: Use Python libs or Java libsOn May 19, 2009, at 4:16 PM, Roger Marquis wrote: > Speaking of runtime, is there a trick to preventing jython from > caching/printing the full build path on exceptions? We don't want > developer usernames (as part of their build path) showing up on end- > user > systems. You can overwrite the default traceback handler via sys.excepthook -- Philip Jenvey ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: Use Python libs or Java libskilon, Tue, 19 May 2009 10:08:06 -0700:
> 1) Is pySqlite3 ported to jython ? Note that there IS JDBC driver for SQLite (http://www.zentus.com/ sqlitejdbc/), and that zxJDBC (which is part of jython) claims to be Python DB API 2.0 compliant (http://www.jython.org/Project/ userfaq.html#can-i-use-the-python-db-api-from-jython). Matěj ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://www.creativitycat.com _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
| Free embeddable forum powered by Nabble | Forum Help |