0

This is an obvious question, that I haven't been able to find a concrete answer to.

Is the Python Byte-Code and Python Code itself interpreter independent,

Meaning by this, that If I take a CPython, PyPy, Jython, IronPython, Skulpt, etc, Interpreter, and I attempt to run, the same piece of code in python or bytecode, will it run correctly? (provided that they implement the same language version, and use modules strictly written in Python or standard modules)

If so, is there is a benchmark, or place where I can compare performance comparison from many interpreters?

I've been playing for a while with CPython, and now I want to explore new interpreters.

And also a side question, What are the uses for the others implementations of python? Skulpt I get it, browsers, but the rest? Is there a specific industry or application that requires a different interpreter (which)?

ekiim
  • 792
  • 1
  • 11
  • 25
  • what do you mean by python bytecode? do you mean pyc files or dis.dis output ? Im pretty sure that pyc files are *roughly* interchangeable ... (probably not skulpt... but maybe) as long as you are only using features that are compatible... I assume the actual bytecode (ie `dis.dis`) is different .... but its all just assumptions ... what is your use case that this matters for? – Joran Beasley Oct 10 '18 at 18:28
  • The assembly like code you get when doing `dis`-assembly a piece of code, the human-readable version of the `pyc` files. – ekiim Oct 10 '18 at 18:31
  • but in either case its easy to test ... and its almost certainly different between versions (ie 2.6 vs 2.7 or 3.1 vs 3.4) – Joran Beasley Oct 10 '18 at 18:36
  • If you run the same python file using diff versions of python, __pycache__ folder will have multiple pyc files with diff python versions attached to the filename. – RyuCoder Oct 10 '18 at 19:22

2 Answers2

0

From https://docs.python.org/3/library/dis.html#module-dis

Bytecode is an implementation detail of the CPython interpreter. No guarantees are made that bytecode will not be added, removed, or changed between versions of Python. Use of this module should not be considered to work across Python VMs or Python releases.

On the other hand, Jython "consists of a compiler to compile Python source code down to Java bytecodes which can run directly on a JVM" and IronPython compiles to CIL to run on the .NET VM.

The purpose is to better integrate into your programming environment. CPython allows you to write C extensions, but this is not necessarily true of other implementations. Jython allows you to interact with Java code. I'm sure similar is true of IronPython.

0

If so, is there is a benchmark, or place where I can compare performance comparison from many interpreters?

speed.pypy.org compares pypy to cpython

mattip
  • 2,360
  • 1
  • 13
  • 13