#jython IRC Log


IRC Log for 2014-01-15

Timestamps are in GMT/BST.

[0:31] * lheuer (~Adium@unaffiliated/lheuer) Quit (Ping timeout: 260 seconds)
[0:47] * willvw (sid20852@gateway/web/irccloud.com/x-nqkiobgafddsamer) has left #jython
[0:48] * arctansusan (~susantan@173-11-98-81-SFBA.hfc.comcastbusiness.net) Quit (Quit: arctansusan)
[0:55] * arctansusan (~susantan@173-11-98-81-SFBA.hfc.comcastbusiness.net) has joined #jython
[3:16] * arctansusan (~susantan@173-11-98-81-SFBA.hfc.comcastbusiness.net) Quit (Quit: arctansusan)
[7:03] * novatago (ae43df1a@gateway/web/freenode/ip. has joined #jython
[7:04] <novatago> Hi.. Anyone know how to instantiate an instance of a generic typed java class in jython?
[7:06] <novatago> for instance, in java : HashSet<Instrument> i = new util.java.HashSet<Instrument>
[7:15] * novatago (ae43df1a@gateway/web/freenode/ip. Quit (Ping timeout: 272 seconds)
[7:18] * lheuer (~Adium@unaffiliated/lheuer) has joined #jython
[7:47] * lheuer (~Adium@unaffiliated/lheuer) Quit (Quit: Leaving.)
[7:49] * lheuer (~Adium@unaffiliated/lheuer) has joined #jython
[8:46] * oscar_toro (~Thunderbi@80-62-162-242-static.dk.customer.tdc.net) has joined #jython
[12:09] * lheuer (~Adium@unaffiliated/lheuer) Quit (Quit: Leaving.)
[13:59] * enebo (~enebo@c-75-73-8-169.hsd1.mn.comcast.net) has joined #jython
[14:49] <jimbaker> novatago, type erasure means this is not actually a jvm concept, only a java one
[14:54] <jimbaker> having said this, this information is still available in the metadata of the code; you can access it by reflection and i believe it's stored using an annotation
[14:55] <jimbaker> but again, not a jvm concept, so we haven't used it in jython
[14:56] <jimbaker> this sort of metadata could potentially be added with clamp, but first need to figure out the specifics :)\
[15:02] <agronholm> he left long ago
[15:08] <jimbaker> agronholm, i know, but when i have a chance, i like to use the log bot to capture these answers
[15:09] <jimbaker> since it is a potentially interesting question - i know guice and spring do play w/ this sort of stuff, and we are now trying to make clamp provide this sort of metadata
[15:10] <jimbaker> at least by supporting annotations. interestingly, i see that java 8 has significant more support for placement of annotations - they can be placed anywhere. so clamp really is about supporting the interface of things
[15:11] <jimbaker> but there is certainly something to be said for helping support more general type checking in the future, by following the flow
[15:11] <jimbaker> http://docs.oracle.com/javase/tutorial/java/annotations/type_annotations.html
[15:48] * whg (~whg@unaffiliated/whg) has joined #jython
[16:11] * novatago (ae43df1a@gateway/web/freenode/ip. has joined #jython
[16:14] * novatago_ (~textual@ip174-67-223-26.oc.oc.cox.net) has joined #jython
[16:17] <novatago_> Thanks Jim. So, I assume that for now, anytime I need to use a generic type, ie List[String] from python, that I'll need to construct the object on the java side and pass the object instance to python through a factory method. Does that make sense? Or is there a better way?
[16:20] <novatago_> Sorry, I meant List<String> (lol, that's my Scala habits leaking through..)
[16:24] * novatago_ (~textual@ip174-67-223-26.oc.oc.cox.net) Quit (Quit: Textual IRC Client: www.textualapp.com)
[16:24] * novatago_ (~textual@ip174-67-223-26.oc.oc.cox.net) has joined #jython
[16:28] * novatago (ae43df1a@gateway/web/freenode/ip. Quit (Ping timeout: 272 seconds)
[16:30] * novatago_ (~textual@ip174-67-223-26.oc.oc.cox.net) has left #jython
[16:30] * novatago_ (~textual@ip174-67-223-26.oc.oc.cox.net) has joined #jython
[16:48] * novatago_ (~textual@ip174-67-223-26.oc.oc.cox.net) Quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz???)
[17:04] * novatago_ (~textual@ip174-67-223-26.oc.oc.cox.net) has joined #jython
[17:07] <novatago_> To be more clear, here is my specific use case: I'm writing a currency trading application in python. This application needs to communicate with a broker for quotes, order entry, etc. The broker provides a java api. I'd like to be able to use the java api from python with as little java wrapper code as possible.
[17:09] <novatago_> The broker API has a method that requires an instance of HashSet<Instrument> to be passed in. I would like to create the HashSet in python before passing it directly to the java api method
[17:14] * novatago_ (~textual@ip174-67-223-26.oc.oc.cox.net) Quit (Quit: Textual IRC Client: www.textualapp.com)
[17:17] * novatago_ (~textual@ip174-67-223-26.oc.oc.cox.net) has joined #jython
[17:25] * novatago_ (~textual@ip174-67-223-26.oc.oc.cox.net) Quit (Quit: Textual IRC Client: www.textualapp.com)
[17:30] * novatago (~novatago@ip174-67-223-26.oc.oc.cox.net) has joined #jython
[17:42] * novatago (~novatago@ip174-67-223-26.oc.oc.cox.net) Quit (Quit: novatago)
[17:42] <jimbaker> novatago, you should not have a problem - there's nothing specifically you need to do in jython for this case of constructing a HashSet - java simply does not retain this parameterization for an instantiated object
[17:43] <ohumbel> novatago, naive syntax may conflict with pure python, e.g. map = HashMap<String, String>() leads to map being a tuple with values (True, False)
[17:43] <ohumbel> so I suggest to simply contstruct a HashSet and put Instrument types into it
[17:43] <jimbaker> ohumbel, correct, that's the implication of type erasure
[17:46] <jimbaker> ohumbel, i also rather like python's parse of "map = HashMap<String, String>()" - that's certainly something that's never occurred to me :)
[17:48] <jimbaker> i can see why String > () is False might make sense, but it's interesting to see that HashMap < String is in fact True
[17:49] <ohumbel> jimbaker, to be honest I just discovered this today
[17:50] <ohumbel> we had a case at work where the called java logic tried to make decisions on the metadata, which is not present if created in jython
[17:50] <ohumbel> and then I started to play around ...
[17:50] <jimbaker> ohumbel, ok i see why this is the case - for types, comparison is based on the hash value
[17:51] <jimbaker> so it's completely arbitrary
[17:51] <ohumbel> jimbaker, cool (I was suspecting something like that)
[17:52] <jimbaker> http://bugs.python.org/issue7491
[17:52] <jimbaker> there must be a test in python for this, so we simply followed what cpython did
[17:53] <jimbaker> ohumbel, back to the metadata stuff - so the java code is using reflection to find type info?
[17:54] <ohumbel> jimbaker, yes exactly
[17:54] <jimbaker> ohumbel, interesting. this really be on the clamp todo then
[17:55] <jimbaker> ohumbel, i did a bit of research on this topic this morning after novatago's question (although for novatago, this probably should not matter)
[17:56] <jimbaker> i read through the java lang spec a bit, but i didn't see any specifics on what the java compiler actually uses for metadata
[17:57] <jimbaker> probably should go through the ASM docs, something like that should be there
[17:57] * enebo (~enebo@c-75-73-8-169.hsd1.mn.comcast.net) Quit (Quit: enebo)
[18:07] <jimbaker> ohumbel, section 4.1 of the asm 4 guide goes into a little bit of detail about working w/ generics - apparently there's a parallel structure in the bytecode for capturing type *signatures*
[18:08] <jimbaker> which can be accessed via this api, http://asm.ow2.org/asm40/javadoc/user/org/objectweb/asm/signature/SignatureVisitor.html
[18:08] <jimbaker> so we could add this w/ clamp. just need to figure out good DSL, the usual
[18:12] <ohumbel> jimbaker, I'll paste our java example in a minute
[18:13] <jimbaker> ohumbel, cool
[18:16] * novatago (~novatago@209-234-187-242.static.twtelecom.net) has joined #jython
[18:19] * enebo (~enebo@c-75-73-8-169.hsd1.mn.comcast.net) has joined #jython
[18:21] <ohumbel> jimbaker, http://pastebin.com/1deBqEAV
[18:22] <jimbaker> ohumbel, exactly - this looks like the beginning of a good test case
[18:22] <ohumbel> this won't compile, but I hope you see the idea. jython would need to create an object of public interface EntityManagerPlug2<View extends IEntityView>
[18:23] <ohumbel> with some abstract superclasses in place
[18:24] <jimbaker> ohumbel, sure - you can do this now if you define the class in java
[18:25] <jimbaker> but you cannot substitute in a python class that extends a java class/implements the necessary interfaces, given this dynamic type checking in the code snippet you pasted
[18:26] <ohumbel> jimbaker, exactly
[18:36] <jimbaker> ohumbel, so ideally in clamp it would be possible to write something like this, https://gist.github.com/jimbaker/8441725
[18:37] <jimbaker> (FooPackage is a metaclass that's generated by clamp, similar to the metaclass mapper used by sqlalchemy - it hides details about __prxoymaker__)
[18:39] <jimbaker> in principle, this is very straightforward to implement, simply need to get class decorators working for clamp that can do the necessary asm transformations. however, this is planned to support class annotations, so it should just piggyback on that
[18:47] <jimbaker> ohumbel, i updated the gist to capture the specific problem we need to solve w/ clamp
[18:50] <jimbaker> very interesting stuff - glad we had this conversation! please note, clamp is back in rather active development. and of course, contributors welcome!
[18:51] <jimbaker> i also just merged in the most recent DSL fixes by darjus
[19:19] * arctansusan (~susantan@173-11-98-81-SFBA.hfc.comcastbusiness.net) has joined #jython
[20:37] * thereisnospoon (~thereisno@113-61-86-28.static.qld.dsl.net.au) Quit (Ping timeout: 265 seconds)
[20:37] * thereisnospoon (~thereisno@113-61-86-28.static.qld.dsl.net.au) has joined #jython
[21:44] <peke> map = HashMap<String, String>() # lol
[21:44] <peke> ohumbel: thanks for sharing!! ^^^
[21:44] <Oti> peek, you're welcome!
[21:45] <Oti> sorry peek/peke
[21:45] <peke> nb
[21:46] <Oti> jimbaker, thanks for the gist!
[21:47] <jimbaker> Oti, np, i thought this was a great conversation
[21:47] <Oti> jimbaker, yes, I learned a lot in a short time - interesting stuff
[21:47] <jimbaker> btw, i hope you like how clamp is currently progressing - it should be quite straightforward to implement that extends class decorator
[21:48] <Oti> jimbaker, sure - hope to be able to participate
[21:48] <jimbaker> absolutely - at the very least, i need your involvement in the DSL design + testing :)
[21:49] <jimbaker> agronholm, Oti, peke - this looks good - https://ep2014.europython.eu/en/proposals/cfp/
[21:49] <jimbaker> fwiw, i plan to submit a proposal to discuss clamp
[21:50] <jimbaker> the deadline for the rfp is feb 10
[21:50] <jimbaker> sorry, feb 9 !
[21:51] <jimbaker> i especially think the metaprogramming stuff we are doing will be of general interest to the python community
[21:51] <jimbaker> as in, how we can avoid writing most of clamp in java, just write it in python instead :)
[21:52] <Oti> jimbaker, that would be really great to have you and clamp at europython
[21:57] <jimbaker> Oti, https://gist.github.com/jimbaker/8445537 - "Clamp uses 6 - or maybe 7 - metaprogramming functionalities available in Python, Jython specifically, and Java"
[21:58] <jimbaker> Oti, so this is something i would highlight in a talk, in addition to the DSL that we expose
[22:50] * enebo (~enebo@c-75-73-8-169.hsd1.mn.comcast.net) Quit (Quit: enebo)
[22:53] * oscar_toro (~Thunderbi@80-62-162-242-static.dk.customer.tdc.net) Quit (Read error: Operation timed out)
[23:16] * mantovan1 (~mantovani@li74-187.members.linode.com) has joined #jython
[23:18] * mantovani (~mantovani@li74-187.members.linode.com) Quit (Ping timeout: 245 seconds)
[23:19] * pjenvey (pjenvey@underboss.org) Quit (Ping timeout: 245 seconds)
[23:20] * pjenvey_ (pjenvey@underboss.org) has joined #jython
[23:29] * vext01 (~edd@host-92-20-137-68.as13285.net) Quit (Ping timeout: 265 seconds)
[23:30] * vext01 (~edd@88-105-199-247.dynamic.dsl.as9105.com) has joined #jython


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