I'm not sure if you're aware of that, but I just described my problem to
the jython-users group. And they told me Clamp is exactly what I'm
looking for. ;) So, first jython, than clamp, then jython, now clamp
again...I'm bit puzzled but I think I understand approximately what
Clamp is designed to do.
I followed your advise, used compile all, built a JAR file containing
the class and the whole Jython lib (I planned to stip it down when it's
working) and then passed it to the Java ME emulator. But is sais "can'T
find MIDlet class". Then I observed the Java byte code generated by
Jython and saw that the resulting class is not implementing MIDlet but
PyRunnable and an $1 has been added to the class name. I think, this
makes it impossible for the emulator to run the MIDlet.
So, I have to admit that I'm not really sure what exactly the "proxy
classes" you were talking about are doing. Alex Grönholm told me, that
you have not finished to implement all proxy generation hooks. But what
are they for? Do they act as correctly named interfaces to other native
Java classes? Something like you generate one proxy class for each
jython class that looks like a class how it should be in Java but which
delivers the calls to subjacent jython classes / methods?
If yes, then it really seems, that Clamp should solve my problem,
Whatever, I already offered you my help. So if there is anything I could
do, just say it. In your first mail, you explained that your work is
half way done but it's still on your working copy and not committed yet.
If you like, I'll be glad to have a look on the current code just to get
an idea what you are doing and how I could possibly help. You could just
send the important classes as a zip file to me. I doesn't have to work,
I doesn't need to be compilable and fully commented, it's just to get an
> -----Ursprüngliche Nachricht-----
> Von: Charlie Groves [mailto:charlie.groves@...]
> Gesendet: Dienstag, 3. November 2009 20:19
> An: Jan Wedel
> Cc: jython-dev@...
> Betreff: Re: AW: Re: [Jython-dev] Clamp Development
> On Nov 2, 2009, at 3:42, "Jan Wedel" <Jan.Wedel@...> wrote:
> > Hi!
> >> If you just want to use arbitrary Python modules in Jython without
> >> dynamic compilation and don't care about exposing them as Java
> >> classes, clamp isn't adding anything. However, one of the things I
> >> added to Jython for clamp is the ability to specify where to store
> >> the
> >> bytecode Jython generates and that stored bytecode should be used
> >> instead of always dynamically generating it. That should allow you
> >> to
> >> use 3rd party libs in a restricted environment.
> > Do you mean Java byte code or Python byte code? If Python actually
> > generates Java byte code, where can I find it? Do you know any
> > documentation by chance, that explains how to generate Java class
> > files
> > or (in an optimal way) create a self-contained jar file from Python
> > code?
> It's java byte code. Whenever you import a module with jython, it
> spits out a $py.class file corresponding to the imported module in
> the same directory. You can use the compileall module included with
> jython to compile a whole directory tree and control where it's
> output. After compiling everything, you no longer need the .py files.
> I think there are a couple guides on the wiki for doing this.
> However jython still generates java bytecode for proxy classes at
> runtime, even if the modules containing the proxy classes are
> precompiled. This is what the proxy generation branch takes care of.
> >> I'm a little worried about your desire for "native speed". Jython
> >> a decently fast implementation of Python, but it's not going to be
> >> fast as plain Java code. I don't have a good feel for what the
> >> is of Java performance to Jython performance these days, especially
> >> for VMs other than Sun's, so I can't say how much slower Jython
> >> be. What level of performance do you need? Maybe someone else
> >> can give you an idea of how Jython will do.
> > I've done some performance tests on my Python Interpreter. It runs
> > 200-300 times slower that the same program coded in "native" Java.
> > Hmm,
> > I think I'm still a bit confused about what Jython does.
> > Is Jython "only" a Java implementation of the CPython interpreter?
> > That
> > would mean, you always need the whole Jython core/interpreter libs
> > create a self contained Jar file. Or, is Jython/Clamp able to create
> > "native" Java byte code without a Python Interpreter in between?
> > Like this:
> > Python source -> Jython Interpreter -> Jython interprets code and
> > executes at runtime in a Java VM
> > Or more like this
> > Python source -> Java byte code -> Java Interpreter of the VM
> > interprets
> > byte code at runtime (Jython not necessary anymore)
> Jython creates bytecode that's run directly by the jvm, but much of
> the core pieces of python are implemented in java and are still needed
> by the generated bytecode. Things like list, dict, int, str and so on
> are contained in jython's jar, so it's still needed by the compiled
> modules. So jython isn't interpreting anything, but it still needs
> some core classes.