Other Integration Topics
In this book, the term integration has largely meant mixing Python with components written in C or C++ (or other C-compatible languages) in extending and embedding modes. But from a broader perspective, integration also includes any other technology that lets us mix Python components into larger systems. This last section briefly looks at a handful of integration technologies beyond the C API tools we’ve seen in this part of the book.
JPython (a.k.a. Jython) Integration
We met JPython in Chapter 15but it is worth another mention in the context of integration at large. As we saw earlier, JPython supports two kinds of integration:
JPython uses Java’s reflection API to allow Python programs to call out to Java class libraries automatically (extending). The Java reflection API provides Java type information at runtime, and serves the same purpose as the glue code we’ve generated to plug C libraries into Python in this part of the book. In JPython, however, this runtime type information allows largely automated resolution of Java calls in Python scripts -- no glue code has to be written or generated.
JPython also provides a Java
PythonInterpreterclass API that allows Java programs to run Python code in a namespace (embedding), much like the C API tools we’ve used to run Python code strings from C programs. In addition, because JPython implements all Python objects as instances of a JavaPyObjectclass, it is straightforward for the Java layer that encloses ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access