|
From: Samuele P. <pe...@in...> - 2001-08-07 01:17:17
|
Hi, I found your mail a bit confusing, maybe there was just too
much meta comments <wink>.
I see three different points:
- jython is slow vs. java
- subclassing a PyObject subclass from jython have problem with mutability of
the instances of the resulting class
This should be solved, probably in 2.2, given that to have a jython 2.2 we
should somehow implement the descr changes
happened to CPython
- a way to solve (partially) both the above problems, although in my opinion
they are unrelated.
In any case adding new keywords and strange semantics is a no-go.
Although I have maybe understood what was the idea behind your words, I don't
want to try to re-explain it confusing
things further, so please please restate it more clearly...
in any case this is an open source projects, prosal and patches are always
welcome.
Samuele Pedroni.
----- Original Message -----
From: john coppola <joh...@ya...>
To: <jyt...@li...>
Sent: Tuesday, August 07, 2001 2:03 AM
Subject: [Jython-dev] Jython and native java merged with simplicity
> After examining the Jython JAPI, it is quite clear
> that the internal operation of the Interpreter is
> quite different. The jAPI of Jython leverages java's
> object oriented nature to implement a Python
> equivalent in java. The jython API has some
> interesting features but has some flaws as well. I
> would like to see these things changed in future
> releases of Jython:
>
> It is very easy to create a true Python class in Java
> using the Jython Api. But, there is, as usual a
> better way to go about things which would make things
> run much faster and with greater flexibility.
>
> Now, one could create a true Python class in java, but
> the performance boost is minimal and not worth the
> time.
>
> Native java code runs much faster. Proof of this is
> the cPickle module implementation in java. The speed
> of "jPickle" is the same speed as cPickle.
>
> Here is a code comparison for a simple program:
> from time import time
> def test():
> start = time()
> total = 0.0
> for i in range(0,1000000):
> total = total + i + i*2.0
> print time()- start
>
> This test on my computer:
> python2.0: 2.77 seconds
> jython2.1a1: 7.40 seconds
> native java: 0.014 seconds
>
> 197 times faster than Python
> 528 times faster than Jython
>
> It would be nice if a python class could leverage the
> speed of java, while having the flexibility of Python.
> We should in theory be able to do this using a Mix-In
> approach.
>
> public class jSpam implements PyObject {
> public pyOb = new PyObject();
>
> public void setOb(PyObject ob) {
> pyOb = ob;
> }
> }
>
>
> import jSpam # true java class
> class Dummy: pass
>
> Class Foo(Dummy,jSpam):
> def __init__(self,name):
> self.name=name
>
> Now, in theory this code should work:
>
> foo=Foo("foo")
>
> This code bombs because inhereting from jSpam has
> interfered with our inheritence from Dummy.
>
> The reason it bombs is because we cannot set
> attributes on the java class we inherited from. This
> makes sense since java is statically typed. We should
> be able to set attributes on the Foo portion of the
> object. Jython does not understand this.
>
>
> We really need to include a feature in Jython that can
> leverage Java's speed with a simple api layer to do
> so.
> For lack of better terminology I'll call it a ghosting
> and skeletons.
>
> Ghosting is the layer in that will provide hooks into
> python types mapped into java skeleton classes. So
> everytime we change a python attribute, the attribute
> is updated in the java skeleton automatically. This
> will in effect pin the Python class to a java class
> removing some of the dynamic flexibility we have with
> the python classes, but the speed gain is tremendous,
> so worth our while.
>
> so in java maybe we have:
>
> public class mySkeleton implements ghosting
>
> the Ghosting interface are the hooks needed by Jython
> to map a Python object to it's skeleton in java
>
> perhaps syntax in Jython would look like:
> from spam import Spam with jSpam skeleton
>
> This would import Spam from the spam module and
> associate the Spam class with the jSpam skeleton.
>
> Alternate syntax may look like:
> from spam import Spam with jSpam skeleton as Spam1
> from spam import Spam with jSpam2 skeleton as Spam2
>
> Where Spam1 and Spam2 have been linked with different
> java skeletons.
>
> A system such as this would provide an easy way to
> utilize java's speed and enable Jython to run several
> times faster than cPython where computationally
> intensive algorithms could be done in the native java
> skeleton class.
>
> John Coppola
>
>
> __________________________________________________
> Do You Yahoo!?
> Make international calls for as low as $.04/minute with Yahoo! Messenger
> http://phonecard.yahoo.com/
>
> _______________________________________________
> Jython-dev mailing list
> Jyt...@li...
> http://lists.sourceforge.net/lists/listinfo/jython-dev
>
|