Skip to main content

Python cross-version byte-code interpeter

Project description

TravisCI CircleCI

x-python

This is a C Python interpreter written Python.

You can use this to:

  • Learn about how the internals of CPython works since this models that

  • Use as a sandboxed environment inside a debugger for trying pieces of execution

  • Have one Python program that runs multiple versions of Python bytecode. For example running Python 2.5 or 2.6 bytecode from Python 3.7. No need to install Python 2.6!

The sandboxed environment in a debugger I find interesting. Since there is a separate execution, and traceback stack, inside a debugger you can try things out in the middle of a debug session without effecting the real execution. On the other hand if a sequence of executions works out, it is possible to copy this (under certain circumstances) back into CPython’s execution stack.

Going the other way, I may at some point hook in my debugger into this interpreter and then you’ll have a conventional pdb/gdb like debugger also with the ability to step bytecode instructions.

Status:

Currently only Python 2.5 - 2.7, and 3.2 - 3.5 bytecode is well understood. Other versions will start to appear with the help of xdis.

Whereas Byterun was a bit loose in accepting bytecode opcodes that is invalid for particular Python but may be valid for another; x-python is more stringent. This has pros and cons. On the plus side Byterun might run certain Python 3.4 bytecode because the opcode sets are similar. However starting with Python 3.5 and beyond the likelihood gets much less because, while the underlying opcode names may be the same, the semantics of the operation may change subtely. See for example https://github.com/nedbat/byterun/issues/34.

Internally Byterun needs the kind of overhaul we have here to be able to scale to support bytecode for more Pythons, and to be able to run bytecode across different versions of Python. Specifically, you can’t rely on Python’s dis module if you expect to expect to run a bytecode other than the bytecode that the interpreter is running.

In x-python there is a clear distinction between the version being interpreted and the version of Python that is running. There is tighter control of opcodes and an opcode’s implementation is kept for each Python version. So we’ll warn early when something is invalid. You can run 3.3 bytecode using Python 3.7 (largely).

The “largely” part is because the interpreter has always made use of Python builtins. When a Python version running the interperter matches a supported bytecode close enough, the interpreter can (and does) make use interpreter internals. For example, built-in functions like range() are supported this way.

However running 2.7 bytecode on 3.x is often not feasible since the runtime and internal libraries used like inspect are too different.

I would say this is more than a a simple toy interpreter, but it will never be as complete as CPython or PyPy.

History

This is a fork of Byterun. which is a pure-Python implementation of a Python bytecode execution virtual machine. Net Batchelder started it (based on work from Paul Swartz) to get a better understanding of bytecodes so he could fix branch coverage bugs in coverage.py.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

x-python-1.0.0.tar.gz (45.3 kB view details)

Uploaded Source

Built Distributions

x_python-1.0.0-py3.5.egg (35.5 kB view details)

Uploaded Egg

x_python-1.0.0-py3.4.egg (35.6 kB view details)

Uploaded Egg

x_python-1.0.0-py3.3.egg (36.1 kB view details)

Uploaded Egg

x_python-1.0.0-py3.2.egg (35.4 kB view details)

Uploaded Egg

x_python-1.0.0-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

x_python-1.0.0-py2.7.egg (35.0 kB view details)

Uploaded Egg

x_python-1.0.0-py2-none-any.whl (18.1 kB view details)

Uploaded Python 2

File details

Details for the file x-python-1.0.0.tar.gz.

File metadata

  • Download URL: x-python-1.0.0.tar.gz
  • Upload date:
  • Size: 45.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/28.8.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.5.9

File hashes

Hashes for x-python-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a32c82059ec3aaeacfff6cbaa23adc7e12faa4558f5e613728614f80e78ee75d
MD5 955df646ef09348dda155907f880e5c6
BLAKE2b-256 2cc00327f58dd8ebbb0d09a479825d8372a15df9113333d59b7aa741b9ba51be

See more details on using hashes here.

File details

Details for the file x_python-1.0.0-py3.5.egg.

File metadata

  • Download URL: x_python-1.0.0-py3.5.egg
  • Upload date:
  • Size: 35.5 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/28.8.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.5.9

File hashes

Hashes for x_python-1.0.0-py3.5.egg
Algorithm Hash digest
SHA256 374680d77c22ea476fe2c24bfd9708e449f2186f7b5915c77603a34b583a5f45
MD5 72563907de2ce579a5bfe2a4979e1a8c
BLAKE2b-256 6135cf193426af570d7a05f0f837478b78c526b2dad41c5ddb3d2b2d6353677e

See more details on using hashes here.

File details

Details for the file x_python-1.0.0-py3.4.egg.

File metadata

  • Download URL: x_python-1.0.0-py3.4.egg
  • Upload date:
  • Size: 35.6 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/28.8.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.5.9

File hashes

Hashes for x_python-1.0.0-py3.4.egg
Algorithm Hash digest
SHA256 0ad90ef90fee6a7a1e9d4ea44afe0168c28dd694b22aa9ade8930cfc01b6c063
MD5 86360c3fb98d11382f11a8ef6fe6e135
BLAKE2b-256 283435a89344e7052800c74409318e6adeb57be419a24e04a457ca46d1e0ae3c

See more details on using hashes here.

File details

Details for the file x_python-1.0.0-py3.3.egg.

File metadata

  • Download URL: x_python-1.0.0-py3.3.egg
  • Upload date:
  • Size: 36.1 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/28.8.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.5.9

File hashes

Hashes for x_python-1.0.0-py3.3.egg
Algorithm Hash digest
SHA256 c9bfa58f5abc17b89d328f7e3c7278da97cc97ea3a4b3965d23fcbc531e1c78d
MD5 07986d009ee809af71b7e034a7a53180
BLAKE2b-256 4ce296d1c565eeaec8ade381c036559f37abef93e291caed717c6269ee809493

See more details on using hashes here.

File details

Details for the file x_python-1.0.0-py3.2.egg.

File metadata

  • Download URL: x_python-1.0.0-py3.2.egg
  • Upload date:
  • Size: 35.4 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/28.8.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.5.9

File hashes

Hashes for x_python-1.0.0-py3.2.egg
Algorithm Hash digest
SHA256 37e2169d21096287040ccb3722c4dda61cac91b284dfde41d30ad18c2e0ed457
MD5 d6fb78bb4f6f62a8dca02a1f06232541
BLAKE2b-256 8a09153a6371e0286893f5e1b3253b1a2eeee9fc6e7c1669249b5bb8dbec71c7

See more details on using hashes here.

File details

Details for the file x_python-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: x_python-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/28.8.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.5.9

File hashes

Hashes for x_python-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 879323a7493f678b7d918d1db7df9771d031fa294caf97cf0dbfd5b20edfaba4
MD5 4afd48d785d87f69331c91711b2938e9
BLAKE2b-256 784b65d6b0660e3c2bae1017a4a7d7460bd57253677dc8350241b37679894fd1

See more details on using hashes here.

File details

Details for the file x_python-1.0.0-py2.7.egg.

File metadata

  • Download URL: x_python-1.0.0-py2.7.egg
  • Upload date:
  • Size: 35.0 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/28.8.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.5.9

File hashes

Hashes for x_python-1.0.0-py2.7.egg
Algorithm Hash digest
SHA256 b18ca2c2506ee52d265f3fbb0a6ecf3aa9f163923c75c269bb89ff786f706b4a
MD5 2b277da28551d01df870a66f8de5cc2f
BLAKE2b-256 a700eb3c518b42d8475c8b547e9d64d1095250a15027364a65975f517c6a8b0f

See more details on using hashes here.

File details

Details for the file x_python-1.0.0-py2-none-any.whl.

File metadata

  • Download URL: x_python-1.0.0-py2-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/28.8.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.5.9

File hashes

Hashes for x_python-1.0.0-py2-none-any.whl
Algorithm Hash digest
SHA256 b2eb44e5be72cc7dfc6d8bc873f1aa730b94df1b5e8d408ab57df7def6df7290
MD5 540dde1afc21ae5ab12a2763ba973a05
BLAKE2b-256 b93ff018d11ce7dcc80e6f94d2edb4be4a94f5de30bfbb939a363d5c493d5ee8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page