Share
Embed
Integrating Python and Java easily using (Micronaut) GraalPy
Cédric Champeau
June 06, 2025
Transcript
18 slides
-
06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:
Internal 1 Cédric Champeau Oracle Social: @[email protected] Integrating Python and Java easily Using (Micronaut) GraalPy -
06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:
Internal 2 About me - Working at Oracle Labs on Micronaut - Main focus on build plugins and dev productivitity - Formerly working at Gradle Inc - Author of static compiler of Groovy - Amateur astronomer https://www.astrobin.com/users/melix/ - Mastodon: @[email protected] -
06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:
Internal 3 About Micronaut - Micronaut is focused on modern architectures like Serverless and Microservices - Also a complete framework for any type of application - Lightweight, reactive (HTTP Client/Server based on Netty) - Annotation processor to compute framework infrastructure at compile time -
06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:
Internal 4 Micronaut: Build Time Framework Infrastructure Micronaut computes: - All dependency & configuration injection - Annotation metadata, meta-annotations - AOP proxies - Bean introspections - And all other framework infrastructure - Reflection, runtime proxy, and dynamic classloader free -
06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:
Internal 5 Micronaut modules Interesting Micronaut modules: - Micronaut Data: AoT compilation of repositories, queries, build time validation with lightweight runtime - Micronaut Sourcegen: language-neutral API for source code generation, replacement for Lombok - Micronaut Serialization: doesn’t use reflection and allows using common annotation models including Jackson annotations, JSON-B annotations or BSON annotations - Micronaut Langchain4j: thin layer over langchain4j -
06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:
Internal 6 GraalVM - High-performance JDK distribution - Increases application throughput, reduces latency, reduces memory use - Graal just-in-time (JIT) compiler that runs on top of HotSpot, written in Java - native-image ahead-of-time (AoT) compiler compiles Java applications into small self-contained native binaries -
06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:
Internal 7 GraalVM Polyglot -
06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:
Internal 8 GraalJS, GraalPy and GraalWasm - Open Source, maintained by GraalVM team - Can run on any OpenJDK distribution - Faster on GraalVM (using Graal compiler) - Supports native image - Plugins for Maven and Gradle -
06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:
Internal 9 GraalPy guides and resources https://www.graalvm.org/python/ -
06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:
Internal 10 Integrating with build tools -
06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:
Internal 11 Demo time! -
06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:
Internal 12 GraalPy plugin - Available for Maven and Gradle - Supports venv creation and packaging -
06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:
Internal 13 Micronaut Graal Languages - Initially supports Python - Exposes Python modules as beans - Deals with context creation boilerplate - Limitation: no multi-context execution -
06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:
Internal 14 Pros and Cons Microservices • ± Independent processes • - Inter process communcation overhead • - Data copy / synchronization / file I/O • + Free to use language runtime for each service Embedded Graal Languages • + All-in-one process, simple deployment • + Low-overhead calls between languages • + Direct data sharing • - Limited to available runtimes and versions of Graal languages • - Native libs sometimes hard to support -
06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:
Internal 15 Threading model • Python has a single thread execution lock • Multiple threads in Java → have to wait for lock – Simple but low throughput • Solution: context pooling (each context is independent) • Beware: not compatible with some Python native libraries! -
06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:
Internal 16 So what’s the catch? • Many Python libraries are actually native (C) • Need to recompile Python packages • Can be slow, or sometimes fail (e.g no Tensorflow for now) • Team is working on precompiled wheels (published to Maven Central or something else) -
06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:
Internal 17 Compatibility • Supports Python 3.11 (3.12 in progress) • Easy upgrade from Jython • Compatible with the top 500 packages on PyPi – See graalvm.org/python/compatibility • Native extensions have to be rebuild from source -
06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:
Internal 18 Resources • GraalPy Quickstart and Guides: https://www.graalvm.org/python/ • Demos: https://github.com/graalvm/graal-languages-demos/ • Micronaut GraalPy: https://micronaut-projects.github.io/micronaut-graal-languages/latest/guide/