#jython IRC Log (v0.9)


IRC Log for 2014-01-16

Timestamps are in GMT/BST.

[1:54] * gthank (~gthank@unaffiliated/gthank) has joined #jython
[1:55] * novatago (~novatago@209-234-187-242.static.twtelecom.net) Quit (Quit: novatago)
[1:55] * gthank (~gthank@unaffiliated/gthank) Quit (Client Quit)
[1:56] * gthank (~gthank@unaffiliated/gthank) has joined #jython
[2:27] * pjenvey_ (pjenvey@underboss.org) Quit (Quit: ZNC - http://znc.sourceforge.net)
[2:28] * pjenvey (pjenvey@underboss.org) has joined #jython
[2:30] * arctansusan (~susantan@173-11-98-81-SFBA.hfc.comcastbusiness.net) Quit (Quit: arctansusan)
[2:55] * gthank (~gthank@unaffiliated/gthank) Quit (Ping timeout: 240 seconds)
[3:38] * novatago (~novatago@ip174-67-223-26.oc.oc.cox.net) has joined #jython
[3:45] <novatago> Type Erasure! Doh! *slaps forehead* of, course. Too many years of c# had me thinking in terms of reification. Sorry for the silly question, but thank you so much for all of your answers. You really helped me get back to the right path.
[4:04] * novatago is now known as tactevo
[5:37] <tactevo> Are there any known issues when calling java method that perform dynamic class loading? I???m calling a java method that instantiates a class like this:
[5:37] <tactevo> Class dcClientImpl = Thread.currentThread().getContextClassLoader().loadClass("com.dukascopy.api.impl.connect.DCClientImpl");
[5:37] <tactevo> client = (IClient) dcClientImpl.newInstance();
[5:38] <tactevo> this works fine in Java, but when calling it from Jython, I get a ClassNotFound exception
[5:38] <tactevo> I know the class path is correct, because I can create a new instance of the class directly in jython like this
[5:39] <tactevo> from com.dukascopy.api.impl.connect import DCClientImpl
[5:39] <tactevo> client = DCClientImpl()
[5:41] <tactevo> I???m using Jython 2.7b1
[5:50] * Arfrever (~Arfrever@apache/committer/Arfrever) has joined #jython
[6:24] <tactevo> I found the problem (or a workaround at least)
[6:25] <tactevo> I???ve been using IntelliJ with the Python plugin.
[6:27] <tactevo> IntelliJ runs my jython file using jython -Dpython.path=**java class path here** run.py
[6:28] <tactevo> using this method, jython can uses the python.path to find java classes, but pure jvm class cannot
[6:29] <tactevo> a simple java test function to print out the class path reveals that from java, the class path does not include the path in -Dpython.path
[6:29] <tactevo> if I add my java classes to the $CLASSPATH env variable, everything works fine
[6:30] <tactevo> I???m just a beginner @ jython, so maybe I???m making a beginner???s mistake setting up the class path.
[6:31] <tactevo> Or maybe, IntelliJ has a bug that passes the wrong arguments for class path to jython on startup
[6:49] <agronholm> tactevo: hold on, are you trying to instantiate a python class from java?
[6:49] <tactevo> no, a java class from jython
[6:50] <agronholm> that code doesn't look like Python
[6:50] <tactevo> it???s java code.
[6:50] <agronholm> do you have that class on the class path?
[6:50] <agronholm> having it on pythonpath isn't enough
[6:50] <tactevo> I guess that???s what I???m figuring out ;)
[6:51] <tactevo> I was confused because I could access the java class from jython/python because the python path pointed to it
[6:51] <tactevo> and the default path configuration that intellij/python uses is for the python path, but not the java classpath
[6:52] <agronholm> how are you loading the class from python then
[6:52] <tactevo> from python, i could just do this
[6:52] <tactevo> from com.dukascopy.api.impl.connect import DCClientImpl
[6:52] <tactevo> client = DCClientImpl()
[6:52] <agronholm> yeah
[6:54] <tactevo> so, I have it working now. But I have to set the java classpath using the $CLASSPATH env variable
[6:55] <tactevo> IntelliJ with the Python plugin claims to be very compatible with Jython.. It allows me to setup Jython as the python interpreter.. and all of it???s ???run??? configurations automatically setup the call to jython
[6:55] <tactevo> But, it doesn???t correctly set the java $CLASSPATH.. it only sets the python.path
[7:17] * tactevo (~novatago@ip174-67-223-26.oc.oc.cox.net) Quit (Quit: tactevo)
[7:59] * oscar_toro (~Thunderbi@80-62-162-242-static.dk.customer.tdc.net) has joined #jython
[8:56] <grey_> Since we are talking classpaths, did anyone understand my proposal (sketch) http://bugs.jython.org/issue2107
[9:14] <peke> jimbaker: yeah, i plan to submit something robot framework related to europython with a colleague. probably both a talk an a training.
[9:15] <peke> definitely planning to check your clamp talk too. should we organize some kind of jython bof too?
[9:21] * ohumbel (5390f2dc@gateway/web/freenode/ip. Quit (Quit: Page closed)
[9:26] * ohumbel (5390f2dc@gateway/web/freenode/ip. has joined #jython
[9:37] <agronholm> how do I get the current class loader from within python code?
[9:37] <agronholm> need it to load resources
[9:37] <agronholm> sys.classLoader is None
[9:39] <agronholm> Thread.getContextClassLoader()?
[9:55] <agronholm> seems to have worked
[10:07] * robbyoconnor (~wakawaka@guifications/user/r0bby) Quit (Read error: Operation timed out)
[10:07] * robbyoconnor (~wakawaka@guifications/user/r0bby) has joined #jython
[12:03] * Oti (~ohumbel@adsl-84-227-120-234.adslplus.ch) Quit (Quit: Oti)
[14:16] * enebo (~enebo@c-75-73-8-169.hsd1.mn.comcast.net) has joined #jython
[14:17] <ohumbel> peke, a jython bof would be nice!
[14:34] * mcurve (~quassel@pop.nakinasystems.com) Quit (Remote host closed the connection)
[14:37] * mcurve (~quassel@pop.nakinasystems.com) has joined #jython
[15:10] * tactevo (~tactevo@ip174-67-223-26.oc.oc.cox.net) has joined #jython
[15:32] * oscar_toro (~Thunderbi@80-62-162-242-static.dk.customer.tdc.net) Quit (Read error: Operation timed out)
[15:48] * tactevo (~tactevo@ip174-67-223-26.oc.oc.cox.net) has left #jython
[16:26] * oscar_toro (~Thunderbi@80-62-162-242-static.dk.customer.tdc.net) has joined #jython
[16:55] <jimbaker> peke, ohumbel - jython BOF is a great idea!
[16:56] <jimbaker> peke, also looking forward to your talk on robot fw
[17:03] * tactevo (~tactevo@ip174-67-223-26.oc.oc.cox.net) has joined #jython
[17:06] <tactevo> As a new Jython user, I???m curious: Why not keep the Jython python.path and the java class path in sync? Or why not add the python.path to the java class path when jython starts?
[17:08] <tactevo> And I???m still not clear why jython can find java classes on the python.path, but jvm code cannot. Isn???t jython using the same class loading methods as java class?
[17:09] <jimbaker> tactevo, so let's look at a typical sys.path - ['', '/Users/jbaker/jythondev/jython27/dist/Lib', '__classpath__', '__pyclasspath__/', '/Users/jbaker/.local/lib/jython2.7/site-packages', '/Users/jbaker/jythondev/jython27/dist/Lib/site-packages']
[17:09] <jimbaker> on there you will see __classpath__, which is actually a special class loader that allows us to import java packages from the CLASSPATH the user specified
[17:10] <tactevo> Ahh
[17:12] <jimbaker> now i think the question you are asking is, why can't i do say Class.forName from some arbitrary class that i have loaded - the problem is, the only thing class loaders will typically agree on (if at all) is CLASSPATH
[17:12] <jimbaker> because the point of a class loader is to go find classes, possibly from arbitrary sources
[17:12] <tactevo> I see now the intended class path functionality.. I guess I???m still trying to figure out why jython could load classes directly in .py code while jvm code loaded from that .py code could not
[17:14] <jimbaker> tactevo, right - of course said jvm code could do this, but you would need to tell it about any changes in sys.path - and there's really no mechanism for working w/ arbitrary class loaders in this way
[17:14] <jimbaker> (maybe osgi solves this??? i don't know osgi however, and it's restricted to osgi if it is)
[17:15] <tactevo> I see. So really, the only way to make sure that jvm code can load classes from the class path is to use the classpath env variable before launching jython, yes?
[17:15] <jimbaker> so that's why CLASSPATH is so important, and also why distribution formats like war, ear, and of course single jar are important
[17:16] <jimbaker> tactevo, correct, that should work. again, an arbitrary class loader need not respect it. but the most important one, Class.forName, does
[17:17] <tactevo> got it.. I really appreciate your help :)
[17:19] <tactevo> by the way, do you have any inside scoop on JyNI dev? I???m wondering how close they are to getting Numpy working with Jython.
[17:22] * tactevo (~tactevo@ip174-67-223-26.oc.oc.cox.net) Quit (Quit: tactevo)
[17:32] * enebo (~enebo@c-75-73-8-169.hsd1.mn.comcast.net) Quit (Quit: enebo)
[17:52] * tactevo (~tactevo@209-234-187-242.static.twtelecom.net) has joined #jython
[18:24] * oscar_toro (~Thunderbi@80-62-162-242-static.dk.customer.tdc.net) Quit (Read error: Operation timed out)
[18:33] * arctansusan (~susantan@173-11-98-81-SFBA.hfc.comcastbusiness.net) has joined #jython
[18:45] * enebo (~enebo@c-75-73-8-169.hsd1.mn.comcast.net) has joined #jython
[18:52] * ohumbel (5390f2dc@gateway/web/freenode/ip. Quit (Ping timeout: 272 seconds)
[19:07] <whg> Jython + NumPy ? that would be an??? interesting??? combination
[19:27] <jimbaker> whg, yes, it would be pretty awesome. note that in general, calling through JNI has overhead and makes it impossible to do certain optimizations
[19:29] <whg> jimbaker: Yes. I'm just curious how many of the benefits of NumPy would be lost: releasing the GIL isn't a win, because Jython doesn't have one, JNI has overhead, like you said, NumPy likes to get fancy with memory layouts if I understand it correctly, etc.
[19:29] <jimbaker> namely inlining. this is especially the case for callbacks back into python
[19:30] <whg> I wonder if NumPyPy (or whatever they're calling it these days) has solved some of those
[19:30] <jimbaker> whg, in general, you want to do bulk ops to avoid boundary costs
[19:30] <jimbaker> fancy memory layouts is less of an issue, because we tend to use sun.misc.Unsafe for direct access when not prohitibted
[19:31] <jimbaker> so long as this fancy layout was known to java code, it would be fast
[19:33] <jimbaker> but overall, it would be a huge win, given that it would enable running numpy in a java env. think of something like hadoop or storm - it would be quite fantastic
[19:33] <whg> I'm rather fuzzy on the details of sun.misc.Unsafe, and how the GC interacts w/ memory allocated by the native side of JNI. The only time I've had to dig into JNI, I did strictly static stuff as far as what had to be passed back from it.
[19:34] <jimbaker> sun.misc.Unsafe allows for directly working w/ bytes, at native instruction speed
[19:34] <jimbaker> cassandra uses this to greatly reduce its overhead
[19:35] <jimbaker> one way to think of sun.misc.Unsafe is that it exposes machine instructions as java method calls. but since they are "intrinsics", you are not actually making method calls. you are executing machine instructions
[19:39] <whg> I imagine that's a fun jump back and forth from Python to assembly and back
[19:39] <whg> (mentally)
[19:40] <jimbaker> whg, it gets easier with practice ;)
[20:05] * mike_af (~mike_af@50-77-49-46-static.hfc.comcastbusiness.net) has joined #jython
[20:11] * tactevo (~tactevo@209-234-187-242.static.twtelecom.net) has left #jython
[20:13] * Oti (~ohumbel@adsl-89-217-225-121.adslplus.ch) has joined #jython
[20:57] * oscar_toro (~Thunderbi@80-62-162-242-static.dk.customer.tdc.net) has joined #jython
[21:10] * robbyoconnor (~wakawaka@guifications/user/r0bby) Quit (Ping timeout: 272 seconds)
[21:17] * oscar_toro (~Thunderbi@80-62-162-242-static.dk.customer.tdc.net) Quit (Read error: Operation timed out)
[21:33] <jimbaker> btw, something worth mentioning from tactevo's earlier question - to hook into jython's classloader, use org.python.core.Py.findClass(name)
[21:33] <jimbaker> this classloader knows about sys.path
[21:34] <jimbaker> (i was looking at clamp's source code to start working on some todo functionality and this popped out)
[21:34] <whg> Do you blog, by any chance?
[21:34] <whg> Because /r/jython over on reddit needs some content
[21:35] <whg> (and members; I went over to check to see if it existed, and I think I'm the 2nd member)
[21:36] <jimbaker> whg, i should blog :(
[21:38] <jimbaker> i have plans to blog on the various projects i'm involved in for jython - clamp, socket-reboot, python on storm, not to mention 2.7. i will do this
[21:39] <whg> Honestly, I don't see how you juggle so much as is, let alone blogging about it, but good on you
[21:41] <jimbaker> whg, my secret is i don't tell people how much i juggle ;)
[21:43] <whg> heh
[21:46] * mike_af (~mike_af@50-77-49-46-static.hfc.comcastbusiness.net) Quit (Quit: Leaving...)
[22:03] * robbyoconnor (~wakawaka@guifications/user/r0bby) has joined #jython
[22:51] * whg (~whg@unaffiliated/whg) Quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz???)
[22:53] * r0bby_ (~wakawaka@guifications/user/r0bby) has joined #jython
[22:54] * robbyoconnor (~wakawaka@guifications/user/r0bby) Quit (Ping timeout: 252 seconds)
[23:11] * r0bby_ (~wakawaka@guifications/user/r0bby) Quit (Read error: No route to host)


These logs were automatically created by JythonLogBot_ on irc.freenode.net using a slightly modified version of the Java IRC LogBot (github).