JyNI -在Jython中使用原生CPython扩展
JyNI - Using native CPython-Extensions in Jython
摘要:
Jython是一个基于Java的Python实现,是集成Python和Java的最无缝的方式。但是,它不支持为CPython编写的本地扩展,如NumPy或SciPy。由于大多数科学Python代码从根本上直接或间接地依赖于这些本地扩展,因此通常不能使用Jython运行。JyNI(Jython Native Interface)旨在缩小这一差距。它是一个层,使Jython用户能够加载本地CPython扩展,并以与在CPython中相同的方式从Jython访问它们。为了利用JyNI功能,您只需在启动Jython时将其放在Java类路径中。它既不需要重新编译扩展代码,也不需要构建定制的Jython分支。这意味着,它与现有的扩展构建是二进制兼容的。在撰写本文时,JyNI还没有完全实现Python C-API,它只能加载只涉及大多数基本内置类型的简单示例。这个概念是相当完整的,我们的目标是尽快提供加载NumPy所需的C-API。之后,我们将专注于SciPy和其他人。我们希望我们的工作也能让Java开发人员在他们的Java代码中使用像NumPy这样的CPython扩展。
英文摘要:
Jython is a Java based Python implementation and the most seamless way to integrate Python and Java. However, it does not support native extensions written for CPython like NumPy or SciPy. Since most scientific Python code fundamentally depends on exactly such native extensions directly or indirectly, it usually cannot be run with Jython. JyNI (Jython Native Interface) aims to close this gap. It is a layer that enables Jython users to load native CPython extensions and access them from Jython the same way as they would do in CPython. In order to leverage the JyNI functionality, you just have to put it on the Java classpath when Jython is launched. It neither requires you to recompile the extension code, nor to build a customized Jython fork. That means, it is binary compatible with existing extension builds. At the time of writing, JyNI does not fully implement the Python C-API and it is only capable of loading simple examples that only involve most basic built-in types. The concept is rather complete though and our goal is to provide the C-API needed to load NumPy as soon as possible. After that we will focus on SciPy and others. We expect that our work will also enable Java developers to use CPython extensions like NumPy in their Java code.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。