CPython、IronPython、Jython 脚本彼此兼容吗?
我很确定 python 脚本可以在所有三个中工作,但我想确定一下。我到处读到过有关可以编写 CPython、Jython、IronPython 的编辑器的信息,我希望我能深入研究其中的区别。
我的情况是我想测试 3 个不同的 api。每个 api 在代码方面执行相同的功能,但它们在实现上有所不同。我正在围绕每种语言的 api 编写包装器。每个包装器都应该使用 Boost::python、Jython 和 IronPython 向 python 公开完全相同的功能和实现。
我的问题是,使用这些公开方法(每种语言都很常见)编写的 Python 脚本是否可以在 Python 的所有三种“风格”中工作?
就像我说的,我很确定答案是“当然”,但在我花太多时间处理这个问题之前,我需要确定一下。
I am pretty sure that python scripts will work in all three, but I want to make sure. I have read here and there about editors that can write CPython, Jython, IronPython and I am hoping that I am looking to much into the distinction.
My situation is I have 3 different api's that I want to test. Each api performs the same functionality code wise, but they are different in implementation. I am writing wrappers around each language's apis. Each wrapper should expose the exact same functionality and implementation to python using Boost::python, Jython, and IronPython.
My question is, would a python script written using these exposed methods (that are common for each language) work in all three "flavors" of Python?
Like I said I am pretty sure the answer is 'Of course,' but I need to make sure before I spend too much time working on this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简短的回答是:有时。
一些基于 IronPython 构建的项目可能无法与 CPython 一起使用,并且一些用 C 编写的 CPython 模块(例如 NumPy)也无法与 IronPython 一起使用。
类似地,虽然 Jython 实现了语言规范,但它与 CPython 存在一些不兼容性(例如,它缺少 CPython 标准库的一些部分,并且它可以导入 Java 标准库包和类,如 Swing)
所以,是的,只要避免不兼容的情况即可。
The short answer is: Sometimes.
Some projects built on top of IronPython may not work with CPython, and some CPython modules that are written in C (e.g. NumPy) will not work with IronPython.
On a similar note, while Jython implements the language specification, it has several incompatibilities with CPython (for instance, it lacks a few parts of the CPython standard library, and it can import Java standard library packages and classes, like Swing)
So, yes, as long as you avoid the incompatibilities.