SlideShare uma empresa Scribd logo
1 de 33
Baixar para ler offline
Jython 2.7 Update
                              Frank Wierzbicki




Wednesday, May 9, 2012
Why use Jython?

                   • Massive amounts of Java code out there
                   • Some really useful Java libs
                   • Great JVM ecosystem
                   • But we’d all rather be writing Python code,
                         right?



Wednesday, May 9, 2012
Status
                   • Jython 2.7 is progresing well
                   • bytearray and io are the last missing big
                         features
                   • 2.7 Unit test compliance
                    • 684 failing tests out of 10786 (~6%)
                    • Most of these are due to bytearray/io
Wednesday, May 9, 2012
Dates

                   • Jython 2.7 work is being sponsored by
                         Adconion. (Thanks!)
                   • Jython 2.7 alpha should be out this month
                   • The target for a production release is July
                         15 - which happens to be the final day of
                         my contract to get Jython to 2.7 :)



Wednesday, May 9, 2012
Why is Adconion
                          sponsoring Jython?
                   • Adconion is a hybrid Java/Python shop
                         based out of LA
                   • They use Python version 2.7 and Jython 2.5
                   • They have internal Django apps that access
                         Java libraries
                   • The 2.5/2.7 differences are a pain
                   • They’d like to give back to the community
Wednesday, May 9, 2012
Collaborators
                   • Major apps
                   • Implementations - CPython, PyPy
                   • Other Java dynamic languages - JRuby
                   • Tooling support
                   • Java Virtual Machine development
                   • Academic research - gradual typing
Wednesday, May 9, 2012
Features
                   • Abstract Base Classes
                   • Bytearray
                   • __format__
                   • OrderedDict
                   • lots of Lib updates
                   • See CPython 2.6/2.7 what’s new for more
Wednesday, May 9, 2012
Not in Jython 2.7

                   • multiprocessing
                   • buffer (so far never has been in Jython)
                   • memoryview (though there is a start, we’ll
                         see)




Wednesday, May 9, 2012
java.util.concurrent
                                                       not interpreted



                            Java Platform
                                                       no GIL

                                                       -J for setting options
                                                       like one of 20 or so GCs
                                                       heap size
                                                       etc




                   • Starting to (optionally) use invokedynamic
                   • Everything is compiled to Java Bytecode
                   • Use a choice of Java garbage collectors
                   • Always uses Java native threads
                   • All cores are used

Wednesday, May 9, 2012
Java Integration

                         • Jython integrates well with Java
                         • Jython makes calling into Java look like
                           standard Python code
                         • Java classes and interfaces can be
                           subclassed from Jython




Wednesday, May 9, 2012
builtin Java interfaces

                   • Jython’s list implements Java List<Object>
                   • Jython’s dict implements Map and
                         ConcurrentMap
                   • Jython’s set implements Java Set


Wednesday, May 9, 2012
//Java interface
    package org.acme;

    public interface MyInterface {
        public List strList();
    }

    #From Python in file “acme.py”
    from org.acme import MyInterface

    class pyobject(MyInterface):
        def strList(self):
            return [‘a’, ‘b’, ‘c’]

    //From Java
    PythonInterpreter interpreter = new PythonInterpreter ();
    interpreter.exec ("from acme import pyobject");
    MyInterface pythonObject = interpreter.get ("pyobject");

    List pywords = pythonObject.strList()
    for (Object o : pyList){
      String string = ((PyObject)o).__toJava__(String.class);
      //Do something with the now Java native strings.
    }


Wednesday, May 9, 2012
PlyJy


                   • For a more sophisticated approach to
                         calling into Python code from Java in Jython
                         see the PlyJy project




Wednesday, May 9, 2012
import org.plyjy.factory.JythonObjectFactory;
           
          JythonObjectFactory factory = JythonObjectFactory.getInstance();
          MyInterface pythonObject = (MyInterface) factory.createObject(
              MyInterface.class, "acme.pyobject");




Wednesday, May 9, 2012
Jython package cache
[frank jython]$ ./dist/bin/jython
*sys-package-mgr*: processing new jar, '/home/frank/hg/jython/jython/dist/jython-dev.jar'
*sys-package-mgr*: processing new jar, '/home/frank/hg/jython/jython/dist/javalib/antlr-2.7.7.jar'
*sys-package-mgr*: processing new jar, '/home/frank/hg/jython/jython/dist/javalib/antlr-3.1.3.jar'
*sys-package-mgr*: processing new jar, '/home/frank/hg/jython/jython/dist/javalib/antlr-runtime-3.1.3.jar'
*sys-package-mgr*: processing new jar, '/home/frank/hg/jython/jython/dist/javalib/asm-4.0.jar'
*sys-package-mgr*: processing new jar, '/home/frank/hg/jython/jython/dist/javalib/asm-commons-4.0.jar'
                                                     ...




Wednesday, May 9, 2012
Java package cache
                   • Goes through all jars and classes and
                         figures out Java package contents
                   • enables “from java.foo import *”
                   • Java does not have a package.getClasses()
                   • If cache is disabled “from java import *” will
                         not work from Jython
                   • * import for pure python still works
Wednesday, May 9, 2012
zxJDBC

                   • zxJDBC implements DB-API
                   • integrated into Jython’s core
                   • A crucial piece for SQLAlchemy, Pyramid
                         and Django support.




Wednesday, May 9, 2012
Modjy

                   • Modjy implements WSGI for Jython
                   • Acts as a bridge to Java Servlets
                   • integrated into Jython’s core
                   • Pyramid and Django support

Wednesday, May 9, 2012
Working apps
                   • SQLAlchemy
                   • Pyramid, DJango
                   • setuptools, ez_install, distribute
                   • virtualenv
                   • pip
                   • many more pure python apps
Wednesday, May 9, 2012
ez_install

                   • Get ez_setup.py
                   • run “jython ez_setup.py”
                   • In Jython’s bin directory will be an
                         ez_install that runs from Jython




Wednesday, May 9, 2012
Install Django
                   • Get 1.3+ Django - run “jython setup.py
                         install”
                   • From http://django-jython.googlecode.com
                         get django-jython-1.3.tar.gz, untar it and run
                         “jython setup.py install”
                   • see the django-jython project on
                         googlecode.com for more detail


Wednesday, May 9, 2012
Deploy Django

                   • run “jython manage.py war --include-java-
                         libs=jdbcdriver.jar”
                   • This will produce a “war file”
                   • Copy this war file to the auto-deploy
                         directory for most application servers (like
                         Tomcat, Jetty or Glassfish)



Wednesday, May 9, 2012
war format for doj
                              |--   WEB-INF
                              |     |-- lib
                              |     `-- lib-python
                              |         |-- Lib
                              |         |-- django
                              |         |-- doj
                              |         `-- mysite
                              `--   media




Wednesday, May 9, 2012
Pyramid on Jython

                   • jython ez_install pyramid
                   • Note that you should not try to use
                         Chameleon with Jython - use Mako for
                         templates.




Wednesday, May 9, 2012
Creating an executable
                            Jar
                   • Make a copy of jython.jar
                   • copy Lib/ into jython.jar
                   • copy a __run__.py file into new jar
                   • in the future it will be a __main__.py to fit
                         with the new CPython convention as of
                         2.6/3.0


Wednesday, May 9, 2012
Add Jython install stuff
                        to a new jar
               $ cd $JYTHON_HOME
               $ cp jython.jar app.jar
               $ zip -r app.jar Lib




Wednesday, May 9, 2012
Add modules and paths
                    to the jar file
               $ cd $MY_APP_DIRECTORY
               $ zip app.jar *.py
               # Add path to additional jar file.
               $ jar ufm myapp.jar othermanifest.mf
               #Where, othermanifest.mf contains the following:
               Class-Path: ./otherjar.jar


Wednesday, May 9, 2012
Add runner file, and
                                run!
               $ zip myapp.jar __run__.py
               #in 2.7/3.x
               $ zip myapp.jar __main__.py
               $ java org.python.util.jython -jar app.jar




Wednesday, May 9, 2012
Jython 3000
                   • We already have a Jython 3 branch
                   • It has a nearly complete parser
                   • Not much else yet
                   • Can’t wait to delete old style classes and
                         fake str suppot!
                   • I’d like to target 3.3 and support only JDK7
                         or above (maybe even JDK8 if it takes long)


Wednesday, May 9, 2012
Jython 3 changes?
                   • All of the same changes as Python3
                    • unicode for all strings
                    • no old style classes
                    • new metaclass syntax
                    • many iterators instead of lists
                    • much more
Wednesday, May 9, 2012
Jython specific changes

                   • Better way to call into Jython? Project
                         Lambda maybe?
                   • Default to not scan packages?
                   • Get rid of swing specific helper functions
                   • Remove Lib gunk

Wednesday, May 9, 2012
Jython/CPython
                               collaboration
                   • Break out the CPython standard Lib into a
                         shared Lib - merge all of Jython’s
                         customizations into CPython Lib
                   • Share CPython’s 3.3 import implementation
                   • PEP 420 implicit namespace packages for
                         Java packages



Wednesday, May 9, 2012
Where to Find Out
                              More
                   • http://www.jython.org
                   • http://wiki.python.org/jython
                   • http://fwierzbicki.blogspot.com
                   • Twitter: fwierzbicki
                   • frank@python.org

Wednesday, May 9, 2012

Mais conteúdo relacionado

Mais procurados

Greach 2014 - Metaprogramming with groovy
Greach 2014 - Metaprogramming with groovyGreach 2014 - Metaprogramming with groovy
Greach 2014 - Metaprogramming with groovyIván López Martín
 
Metaprogramming with Groovy
Metaprogramming with GroovyMetaprogramming with Groovy
Metaprogramming with GroovyAli Tanwir
 
Groovy AST Demystified
Groovy AST DemystifiedGroovy AST Demystified
Groovy AST DemystifiedAndres Almiray
 
Introduction to Groovy runtime metaprogramming and AST transforms
Introduction to Groovy runtime metaprogramming and AST transformsIntroduction to Groovy runtime metaprogramming and AST transforms
Introduction to Groovy runtime metaprogramming and AST transformsMarcin Grzejszczak
 
QTP Interview Questions and answers
QTP Interview Questions and answersQTP Interview Questions and answers
QTP Interview Questions and answersRita Singh
 
Groovy AST Transformations
Groovy AST TransformationsGroovy AST Transformations
Groovy AST Transformationshendersk
 
Rifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobotRifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobotTsai Tsung-Yi
 
Using the Groovy Ecosystem for Rapid JVM Development
Using the Groovy Ecosystem for Rapid JVM DevelopmentUsing the Groovy Ecosystem for Rapid JVM Development
Using the Groovy Ecosystem for Rapid JVM DevelopmentSchalk Cronjé
 
Qtp interview questions and answers
Qtp interview questions and answersQtp interview questions and answers
Qtp interview questions and answersITeLearn
 
Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machineLaxman Puri
 
Introduction to Kotlin for Java developer
Introduction to Kotlin for Java developerIntroduction to Kotlin for Java developer
Introduction to Kotlin for Java developerShuhei Shogen
 
Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011Anton Arhipov
 
Integration Group - Robot Framework
Integration Group - Robot Framework Integration Group - Robot Framework
Integration Group - Robot Framework OpenDaylight
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to javaAjay Sharma
 
Java 7 Language Enhancement
Java 7 Language EnhancementJava 7 Language Enhancement
Java 7 Language Enhancementmuthusvm
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyNick Sieger
 
Qtp Interview Questions
Qtp Interview QuestionsQtp Interview Questions
Qtp Interview Questionskspanigra
 

Mais procurados (20)

Greach 2014 - Metaprogramming with groovy
Greach 2014 - Metaprogramming with groovyGreach 2014 - Metaprogramming with groovy
Greach 2014 - Metaprogramming with groovy
 
Metaprogramming with Groovy
Metaprogramming with GroovyMetaprogramming with Groovy
Metaprogramming with Groovy
 
Groovy AST Demystified
Groovy AST DemystifiedGroovy AST Demystified
Groovy AST Demystified
 
Ast transformation
Ast transformationAst transformation
Ast transformation
 
Introduction to Groovy runtime metaprogramming and AST transforms
Introduction to Groovy runtime metaprogramming and AST transformsIntroduction to Groovy runtime metaprogramming and AST transforms
Introduction to Groovy runtime metaprogramming and AST transforms
 
QTP Interview Questions and answers
QTP Interview Questions and answersQTP Interview Questions and answers
QTP Interview Questions and answers
 
Java For Automation
Java   For AutomationJava   For Automation
Java For Automation
 
Groovy AST Transformations
Groovy AST TransformationsGroovy AST Transformations
Groovy AST Transformations
 
Rifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobotRifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobot
 
Using the Groovy Ecosystem for Rapid JVM Development
Using the Groovy Ecosystem for Rapid JVM DevelopmentUsing the Groovy Ecosystem for Rapid JVM Development
Using the Groovy Ecosystem for Rapid JVM Development
 
Qtp interview questions and answers
Qtp interview questions and answersQtp interview questions and answers
Qtp interview questions and answers
 
Kotlin - Better Java
Kotlin - Better JavaKotlin - Better Java
Kotlin - Better Java
 
Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machine
 
Introduction to Kotlin for Java developer
Introduction to Kotlin for Java developerIntroduction to Kotlin for Java developer
Introduction to Kotlin for Java developer
 
Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011
 
Integration Group - Robot Framework
Integration Group - Robot Framework Integration Group - Robot Framework
Integration Group - Robot Framework
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Java 7 Language Enhancement
Java 7 Language EnhancementJava 7 Language Enhancement
Java 7 Language Enhancement
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRuby
 
Qtp Interview Questions
Qtp Interview QuestionsQtp Interview Questions
Qtp Interview Questions
 

Destaque

Jython: Integrating Python and Java
Jython: Integrating Python and JavaJython: Integrating Python and Java
Jython: Integrating Python and JavaCharles Anderson
 
[PyCon 2014 APAC] How to integrate python into a scala stack to build realtim...
[PyCon 2014 APAC] How to integrate python into a scala stack to build realtim...[PyCon 2014 APAC] How to integrate python into a scala stack to build realtim...
[PyCon 2014 APAC] How to integrate python into a scala stack to build realtim...Jerry Chou
 
How to integrate python into a scala stack
How to integrate python into a scala stackHow to integrate python into a scala stack
How to integrate python into a scala stackFliptop
 
KScope14 Jython Scripting
KScope14 Jython ScriptingKScope14 Jython Scripting
KScope14 Jython ScriptingAlithya
 
Top 10 Bad Coding Practices Lead to Security Problems
Top 10 Bad Coding Practices Lead to Security ProblemsTop 10 Bad Coding Practices Lead to Security Problems
Top 10 Bad Coding Practices Lead to Security ProblemsNarudom Roongsiriwong, CISSP
 
Lecture7 การแปลงโมเดลแบบ E-R เป็นรูปแบบโมเดลเชิงสัมพันธ์
Lecture7 การแปลงโมเดลแบบ E-R เป็นรูปแบบโมเดลเชิงสัมพันธ์Lecture7 การแปลงโมเดลแบบ E-R เป็นรูปแบบโมเดลเชิงสัมพันธ์
Lecture7 การแปลงโมเดลแบบ E-R เป็นรูปแบบโมเดลเชิงสัมพันธ์skiats
 
Network ve Sistem 101 etkinliği
Network ve Sistem 101 etkinliği Network ve Sistem 101 etkinliği
Network ve Sistem 101 etkinliği Ahmet Han
 
Embracing Distributed Version Control
Embracing Distributed Version ControlEmbracing Distributed Version Control
Embracing Distributed Version ControlNowell Strite
 
Dağıtık Sistemler İçin Mahremiyet Korumalı Uç Öğrenme Makinesi Sınıflandırma ...
Dağıtık Sistemler İçin Mahremiyet Korumalı Uç Öğrenme Makinesi Sınıflandırma ...Dağıtık Sistemler İçin Mahremiyet Korumalı Uç Öğrenme Makinesi Sınıflandırma ...
Dağıtık Sistemler İçin Mahremiyet Korumalı Uç Öğrenme Makinesi Sınıflandırma ...Ferhat Ozgur Catak
 
Network101 murat arslan
Network101 murat arslanNetwork101 murat arslan
Network101 murat arslanMURAT ARSLAN
 
IP Security
IP SecurityIP Security
IP SecurityS H
 
Secure Multi-Party Computation Based Privacy Preserving Extreme Learning Mach...
Secure Multi-Party Computation Based Privacy Preserving Extreme Learning Mach...Secure Multi-Party Computation Based Privacy Preserving Extreme Learning Mach...
Secure Multi-Party Computation Based Privacy Preserving Extreme Learning Mach...Ferhat Ozgur Catak
 
The Agile Process - Taming Your Process To Work For You
The Agile Process - Taming Your Process To Work For YouThe Agile Process - Taming Your Process To Work For You
The Agile Process - Taming Your Process To Work For YouNowell Strite
 

Destaque (20)

Jython: Integrating Python and Java
Jython: Integrating Python and JavaJython: Integrating Python and Java
Jython: Integrating Python and Java
 
Python Course #1
Python Course #1Python Course #1
Python Course #1
 
Git and github introduction
Git and github introductionGit and github introduction
Git and github introduction
 
[PyCon 2014 APAC] How to integrate python into a scala stack to build realtim...
[PyCon 2014 APAC] How to integrate python into a scala stack to build realtim...[PyCon 2014 APAC] How to integrate python into a scala stack to build realtim...
[PyCon 2014 APAC] How to integrate python into a scala stack to build realtim...
 
How to integrate python into a scala stack
How to integrate python into a scala stackHow to integrate python into a scala stack
How to integrate python into a scala stack
 
Python y Flink
Python y FlinkPython y Flink
Python y Flink
 
KScope14 Jython Scripting
KScope14 Jython ScriptingKScope14 Jython Scripting
KScope14 Jython Scripting
 
บทที่ 5 การแปลง er diagram ให้เป็น table
บทที่ 5 การแปลง er diagram ให้เป็น tableบทที่ 5 การแปลง er diagram ให้เป็น table
บทที่ 5 การแปลง er diagram ให้เป็น table
 
Python to scala
Python to scalaPython to scala
Python to scala
 
Top 10 Bad Coding Practices Lead to Security Problems
Top 10 Bad Coding Practices Lead to Security ProblemsTop 10 Bad Coding Practices Lead to Security Problems
Top 10 Bad Coding Practices Lead to Security Problems
 
Lecture7 การแปลงโมเดลแบบ E-R เป็นรูปแบบโมเดลเชิงสัมพันธ์
Lecture7 การแปลงโมเดลแบบ E-R เป็นรูปแบบโมเดลเชิงสัมพันธ์Lecture7 การแปลงโมเดลแบบ E-R เป็นรูปแบบโมเดลเชิงสัมพันธ์
Lecture7 การแปลงโมเดลแบบ E-R เป็นรูปแบบโมเดลเชิงสัมพันธ์
 
Network ve Sistem 101 etkinliği
Network ve Sistem 101 etkinliği Network ve Sistem 101 etkinliği
Network ve Sistem 101 etkinliği
 
Tablo oluşturma
Tablo oluşturmaTablo oluşturma
Tablo oluşturma
 
Embracing Distributed Version Control
Embracing Distributed Version ControlEmbracing Distributed Version Control
Embracing Distributed Version Control
 
Dağıtık Sistemler İçin Mahremiyet Korumalı Uç Öğrenme Makinesi Sınıflandırma ...
Dağıtık Sistemler İçin Mahremiyet Korumalı Uç Öğrenme Makinesi Sınıflandırma ...Dağıtık Sistemler İçin Mahremiyet Korumalı Uç Öğrenme Makinesi Sınıflandırma ...
Dağıtık Sistemler İçin Mahremiyet Korumalı Uç Öğrenme Makinesi Sınıflandırma ...
 
Hesaplamalarım
HesaplamalarımHesaplamalarım
Hesaplamalarım
 
Network101 murat arslan
Network101 murat arslanNetwork101 murat arslan
Network101 murat arslan
 
IP Security
IP SecurityIP Security
IP Security
 
Secure Multi-Party Computation Based Privacy Preserving Extreme Learning Mach...
Secure Multi-Party Computation Based Privacy Preserving Extreme Learning Mach...Secure Multi-Party Computation Based Privacy Preserving Extreme Learning Mach...
Secure Multi-Party Computation Based Privacy Preserving Extreme Learning Mach...
 
The Agile Process - Taming Your Process To Work For You
The Agile Process - Taming Your Process To Work For YouThe Agile Process - Taming Your Process To Work For You
The Agile Process - Taming Your Process To Work For You
 

Semelhante a Jython 2.7 and techniques for integrating with Java - Frank Wierzbicki

Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)
Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)
Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)Mihail Stoynov
 
2011 june-kuala-lumpur-gtug-hackathon
2011 june-kuala-lumpur-gtug-hackathon2011 june-kuala-lumpur-gtug-hackathon
2011 june-kuala-lumpur-gtug-hackathonikailan
 
Jython on Django
Jython on DjangoJython on Django
Jython on Djangofwierzbicki
 
JVM for Dummies - OSCON 2011
JVM for Dummies - OSCON 2011JVM for Dummies - OSCON 2011
JVM for Dummies - OSCON 2011Charles Nutter
 
What's Expected in Java 7
What's Expected in Java 7What's Expected in Java 7
What's Expected in Java 7Gal Marder
 
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
10 clues showing that you are doing OSGi in the wrong manner - Jerome Molieremfrancis
 
What we can expect from Java 9 by Ivan Krylov
What we can expect from Java 9 by Ivan KrylovWhat we can expect from Java 9 by Ivan Krylov
What we can expect from Java 9 by Ivan KrylovJ On The Beach
 
Django Deployment with Fabric
Django Deployment with FabricDjango Deployment with Fabric
Django Deployment with FabricJonas Nockert
 
Pitfalls of Continuous Deployment
Pitfalls of Continuous DeploymentPitfalls of Continuous Deployment
Pitfalls of Continuous Deploymentzeeg
 
Java: Rumours of my demise are greatly exaggerated
Java: Rumours of my demise are greatly exaggeratedJava: Rumours of my demise are greatly exaggerated
Java: Rumours of my demise are greatly exaggeratedSteve Dalton
 
The Diabolical Developer's Guide to Surviving Java 9
The Diabolical Developer's Guide to Surviving Java 9The Diabolical Developer's Guide to Surviving Java 9
The Diabolical Developer's Guide to Surviving Java 9jClarity
 
Cloud-ready Micro Java EE 8
Cloud-ready Micro Java EE 8Cloud-ready Micro Java EE 8
Cloud-ready Micro Java EE 8Payara
 
Launchpad: Lessons Learnt
Launchpad: Lessons LearntLaunchpad: Lessons Learnt
Launchpad: Lessons LearntTim Penhey
 

Semelhante a Jython 2.7 and techniques for integrating with Java - Frank Wierzbicki (20)

Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)
Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)
Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)
 
2011 june-kuala-lumpur-gtug-hackathon
2011 june-kuala-lumpur-gtug-hackathon2011 june-kuala-lumpur-gtug-hackathon
2011 june-kuala-lumpur-gtug-hackathon
 
Jython on Django
Jython on DjangoJython on Django
Jython on Django
 
JVM for Dummies - OSCON 2011
JVM for Dummies - OSCON 2011JVM for Dummies - OSCON 2011
JVM for Dummies - OSCON 2011
 
What's Expected in Java 7
What's Expected in Java 7What's Expected in Java 7
What's Expected in Java 7
 
Java 9 preview
Java 9 previewJava 9 preview
Java 9 preview
 
Základy GWT
Základy GWTZáklady GWT
Základy GWT
 
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
 
What we can expect from Java 9 by Ivan Krylov
What we can expect from Java 9 by Ivan KrylovWhat we can expect from Java 9 by Ivan Krylov
What we can expect from Java 9 by Ivan Krylov
 
Railsconf 2010
Railsconf 2010Railsconf 2010
Railsconf 2010
 
Django Deployment with Fabric
Django Deployment with FabricDjango Deployment with Fabric
Django Deployment with Fabric
 
Modularization in java 8
Modularization in java 8Modularization in java 8
Modularization in java 8
 
FreshAir2008
FreshAir2008FreshAir2008
FreshAir2008
 
FreshAir2008
FreshAir2008FreshAir2008
FreshAir2008
 
Pitfalls of Continuous Deployment
Pitfalls of Continuous DeploymentPitfalls of Continuous Deployment
Pitfalls of Continuous Deployment
 
Java: Rumours of my demise are greatly exaggerated
Java: Rumours of my demise are greatly exaggeratedJava: Rumours of my demise are greatly exaggerated
Java: Rumours of my demise are greatly exaggerated
 
The Diabolical Developer's Guide to Surviving Java 9
The Diabolical Developer's Guide to Surviving Java 9The Diabolical Developer's Guide to Surviving Java 9
The Diabolical Developer's Guide to Surviving Java 9
 
Cloud-ready Micro Java EE 8
Cloud-ready Micro Java EE 8Cloud-ready Micro Java EE 8
Cloud-ready Micro Java EE 8
 
Launchpad: Lessons Learnt
Launchpad: Lessons LearntLaunchpad: Lessons Learnt
Launchpad: Lessons Learnt
 
Testing in GO
Testing in GOTesting in GO
Testing in GO
 

Último

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 

Último (20)

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 

Jython 2.7 and techniques for integrating with Java - Frank Wierzbicki

  • 1. Jython 2.7 Update Frank Wierzbicki Wednesday, May 9, 2012
  • 2. Why use Jython? • Massive amounts of Java code out there • Some really useful Java libs • Great JVM ecosystem • But we’d all rather be writing Python code, right? Wednesday, May 9, 2012
  • 3. Status • Jython 2.7 is progresing well • bytearray and io are the last missing big features • 2.7 Unit test compliance • 684 failing tests out of 10786 (~6%) • Most of these are due to bytearray/io Wednesday, May 9, 2012
  • 4. Dates • Jython 2.7 work is being sponsored by Adconion. (Thanks!) • Jython 2.7 alpha should be out this month • The target for a production release is July 15 - which happens to be the final day of my contract to get Jython to 2.7 :) Wednesday, May 9, 2012
  • 5. Why is Adconion sponsoring Jython? • Adconion is a hybrid Java/Python shop based out of LA • They use Python version 2.7 and Jython 2.5 • They have internal Django apps that access Java libraries • The 2.5/2.7 differences are a pain • They’d like to give back to the community Wednesday, May 9, 2012
  • 6. Collaborators • Major apps • Implementations - CPython, PyPy • Other Java dynamic languages - JRuby • Tooling support • Java Virtual Machine development • Academic research - gradual typing Wednesday, May 9, 2012
  • 7. Features • Abstract Base Classes • Bytearray • __format__ • OrderedDict • lots of Lib updates • See CPython 2.6/2.7 what’s new for more Wednesday, May 9, 2012
  • 8. Not in Jython 2.7 • multiprocessing • buffer (so far never has been in Jython) • memoryview (though there is a start, we’ll see) Wednesday, May 9, 2012
  • 9. java.util.concurrent not interpreted Java Platform no GIL -J for setting options like one of 20 or so GCs heap size etc • Starting to (optionally) use invokedynamic • Everything is compiled to Java Bytecode • Use a choice of Java garbage collectors • Always uses Java native threads • All cores are used Wednesday, May 9, 2012
  • 10. Java Integration • Jython integrates well with Java • Jython makes calling into Java look like standard Python code • Java classes and interfaces can be subclassed from Jython Wednesday, May 9, 2012
  • 11. builtin Java interfaces • Jython’s list implements Java List<Object> • Jython’s dict implements Map and ConcurrentMap • Jython’s set implements Java Set Wednesday, May 9, 2012
  • 12. //Java interface package org.acme; public interface MyInterface { public List strList(); } #From Python in file “acme.py” from org.acme import MyInterface class pyobject(MyInterface): def strList(self): return [‘a’, ‘b’, ‘c’] //From Java PythonInterpreter interpreter = new PythonInterpreter (); interpreter.exec ("from acme import pyobject"); MyInterface pythonObject = interpreter.get ("pyobject"); List pywords = pythonObject.strList() for (Object o : pyList){   String string = ((PyObject)o).__toJava__(String.class); //Do something with the now Java native strings. } Wednesday, May 9, 2012
  • 13. PlyJy • For a more sophisticated approach to calling into Python code from Java in Jython see the PlyJy project Wednesday, May 9, 2012
  • 14. import org.plyjy.factory.JythonObjectFactory;   JythonObjectFactory factory = JythonObjectFactory.getInstance(); MyInterface pythonObject = (MyInterface) factory.createObject( MyInterface.class, "acme.pyobject"); Wednesday, May 9, 2012
  • 15. Jython package cache [frank jython]$ ./dist/bin/jython *sys-package-mgr*: processing new jar, '/home/frank/hg/jython/jython/dist/jython-dev.jar' *sys-package-mgr*: processing new jar, '/home/frank/hg/jython/jython/dist/javalib/antlr-2.7.7.jar' *sys-package-mgr*: processing new jar, '/home/frank/hg/jython/jython/dist/javalib/antlr-3.1.3.jar' *sys-package-mgr*: processing new jar, '/home/frank/hg/jython/jython/dist/javalib/antlr-runtime-3.1.3.jar' *sys-package-mgr*: processing new jar, '/home/frank/hg/jython/jython/dist/javalib/asm-4.0.jar' *sys-package-mgr*: processing new jar, '/home/frank/hg/jython/jython/dist/javalib/asm-commons-4.0.jar' ... Wednesday, May 9, 2012
  • 16. Java package cache • Goes through all jars and classes and figures out Java package contents • enables “from java.foo import *” • Java does not have a package.getClasses() • If cache is disabled “from java import *” will not work from Jython • * import for pure python still works Wednesday, May 9, 2012
  • 17. zxJDBC • zxJDBC implements DB-API • integrated into Jython’s core • A crucial piece for SQLAlchemy, Pyramid and Django support. Wednesday, May 9, 2012
  • 18. Modjy • Modjy implements WSGI for Jython • Acts as a bridge to Java Servlets • integrated into Jython’s core • Pyramid and Django support Wednesday, May 9, 2012
  • 19. Working apps • SQLAlchemy • Pyramid, DJango • setuptools, ez_install, distribute • virtualenv • pip • many more pure python apps Wednesday, May 9, 2012
  • 20. ez_install • Get ez_setup.py • run “jython ez_setup.py” • In Jython’s bin directory will be an ez_install that runs from Jython Wednesday, May 9, 2012
  • 21. Install Django • Get 1.3+ Django - run “jython setup.py install” • From http://django-jython.googlecode.com get django-jython-1.3.tar.gz, untar it and run “jython setup.py install” • see the django-jython project on googlecode.com for more detail Wednesday, May 9, 2012
  • 22. Deploy Django • run “jython manage.py war --include-java- libs=jdbcdriver.jar” • This will produce a “war file” • Copy this war file to the auto-deploy directory for most application servers (like Tomcat, Jetty or Glassfish) Wednesday, May 9, 2012
  • 23. war format for doj |-- WEB-INF | |-- lib | `-- lib-python | |-- Lib | |-- django | |-- doj | `-- mysite `-- media Wednesday, May 9, 2012
  • 24. Pyramid on Jython • jython ez_install pyramid • Note that you should not try to use Chameleon with Jython - use Mako for templates. Wednesday, May 9, 2012
  • 25. Creating an executable Jar • Make a copy of jython.jar • copy Lib/ into jython.jar • copy a __run__.py file into new jar • in the future it will be a __main__.py to fit with the new CPython convention as of 2.6/3.0 Wednesday, May 9, 2012
  • 26. Add Jython install stuff to a new jar $ cd $JYTHON_HOME $ cp jython.jar app.jar $ zip -r app.jar Lib Wednesday, May 9, 2012
  • 27. Add modules and paths to the jar file $ cd $MY_APP_DIRECTORY $ zip app.jar *.py # Add path to additional jar file. $ jar ufm myapp.jar othermanifest.mf #Where, othermanifest.mf contains the following: Class-Path: ./otherjar.jar Wednesday, May 9, 2012
  • 28. Add runner file, and run! $ zip myapp.jar __run__.py #in 2.7/3.x $ zip myapp.jar __main__.py $ java org.python.util.jython -jar app.jar Wednesday, May 9, 2012
  • 29. Jython 3000 • We already have a Jython 3 branch • It has a nearly complete parser • Not much else yet • Can’t wait to delete old style classes and fake str suppot! • I’d like to target 3.3 and support only JDK7 or above (maybe even JDK8 if it takes long) Wednesday, May 9, 2012
  • 30. Jython 3 changes? • All of the same changes as Python3 • unicode for all strings • no old style classes • new metaclass syntax • many iterators instead of lists • much more Wednesday, May 9, 2012
  • 31. Jython specific changes • Better way to call into Jython? Project Lambda maybe? • Default to not scan packages? • Get rid of swing specific helper functions • Remove Lib gunk Wednesday, May 9, 2012
  • 32. Jython/CPython collaboration • Break out the CPython standard Lib into a shared Lib - merge all of Jython’s customizations into CPython Lib • Share CPython’s 3.3 import implementation • PEP 420 implicit namespace packages for Java packages Wednesday, May 9, 2012
  • 33. Where to Find Out More • http://www.jython.org • http://wiki.python.org/jython • http://fwierzbicki.blogspot.com • Twitter: fwierzbicki • frank@python.org Wednesday, May 9, 2012