Are CPython, IronPython, Jython scripts compatible with each other?

2024/10/10 18:19:38

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.

Answer

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.

https://en.xdnf.cn/q/69867.html

Related Q&A

Python. Print mac address out of 6 byte string

I have mac address in 6 byte string. How would you print it in "human" readable format?Thanks

Cursors with postgres, where is the data stored and how many calls to the DB

Hi I am using psycopg2 for postgres access.I am trying to understand where "cursor" stores the returned rows. Does it store it in the database as a temporary table or is it on the clients en…

Django - How to allow only the owner of a new post to edit or delete the post?

I will be really grateful if anyone can help to resolve the issue below. I have the following Django project coding. The problem is: when the browser was given "/posts/remove/<post_id>/"…

Py4J has bigger overhead than Jython and JPype

After searching for an option to run Java code from Django application(python), I found out that Py4J is the best option for me. I tried Jython, JPype and Python subprocess and each of them have certai…

how to uninstall opencv-python package installed by using pip in anaconda?

I have tried to install OpenCV in anaconda. but when I use it, I figure out the instead of using OpenCV, the program using OpenCV-python and that why my program crashed. I type "conda uninstall op…

flask many to many join as done by prefetch_related from django

I have following Group and Contact model in flask with Sql Alchemy ORMgroup_contact = db.Table(group_contact,db.Column(group_id, db.Integer, db.ForeignKey(group.id)),db.Column(contact_id, db.Integer, d…

Django model inheritance - only want instances of parent class in a query

Lets say I have 2 models, one being the parent of another. How can I query all Places that arent restaurants in Django? Place.objects.all() would include all restaurants right? I want to exclude the …

Perfom python unit tests via a web interface

Is it possible to perform unittest tests via a web interface...and if so how?EDIT: For now I want the results...for the tests I want them to be automated...possibly every time I make a change to the …

Limit on number of HDF5 Datasets

Using h5py to create a hdf5-file with many datasets, I encounter a massive Speed drop after ca. 2,88 mio datasets. What is the reason for this?I assume that the limit of the tree structure for the dat…

Object level cascading permission in Django

Projects such as Django-guardian and django-permissions enables you to have object level permissions. However, if two objects are related to each other by a parent-child relationship, is there any way …