Pyonic Python 3 interpreter Android latest 1.3.1 APK Download and Install. A Python 3 interpreter interface, written in Python using Kivy. This is an interpreter and has a foreign function interface with languages like C. Here's a brief on it-Developers-Python code developers, the Python community; Stable Release-3.6.5; March, 2018 and 2.7.15; May, 2018; Written in-C; Type-Python programming language interpreter. Core and Builtins- Issue #3996: On Windows, the PyOSCheckStack function would cause the interpreter to abort ('Fatal Python error: Could not reset the stack!' Download the latest Python 3 and Python 2 source. Alternative Implementations. Larry Hastings (3.5.x source files and tags) (key id: 3A5C A953 F73C 700D).
Released:
Python cross-version byte-code interpeter
Project description
x-python
This is a CPython bytecode interpreter written Python.
You can use this to:
- Learn about how the internals of CPython works since this models that
- Experiment with additional opcodes, or ways to change the run-time environment
- Use as a sandboxed environment for trying pieces of execution
- Have one Python program that runs multiple versions of Python bytecode.
- Use in a dynamic fuzzer or in coholic execution for analysis
The ability to run Python bytecode as far back as 2.4 from Python 3.7I find pretty neat. (Even more could easily be added).
Also, The sandboxed environment in a debugger I findinteresting. (Note: currently environments are not sandboxed thatwell, but I am working towards that.)
Since there is a separate execution, and traceback stack,inside a debugger you can try things out in the middle of a debugsession without effecting the real execution. On the other hand if asequence of executions works out, it is possible to copy this (undercertain circumstances) back into CPython's execution stack.
Going the other way, I have hooked in trepan3k into this interpreter so youhave a pdb/gdb like debugger also with the ability to step bytecodeinstructions.
To experiment with faster ways to support trace callbacks such asthose used in a debugger. In particular added an instruction tosupport fast breakpoints and breakpointing on a particular instructionthat doesn't happen to be on a line boundary. I believe this couldcould and should be ported back to CPython and there would be benefit.(Python 3.8 supports the ability to save additional frame information whichis where the original opcode is stored. It just needs the BRKPT opcode)
Although this is far in the future, suppose you to add a racedetector? It might be easier to prototype it in Python here. (Thisassumes the interpreter supports threading well, I suspect it doesn't)
Another unexplored avenue implied above is mixing interpretation anddirect CPython execution. In fact, there are bugs so this happensright now, but it will be turned into a feature. Some functions orclasses you may want to not run under a slow interpreter while othersyou do want to run under the interpreter.
Examples:
What to know instructions get run when you write some simple code?Try this:
Option -c is the same as Python's flag (program passed in as string)and -v is also analogus Python's flag. Here, it shows the bytecodeinstructions run.
Note that the disassembly above in the dynamic trace above gives alittle more than what you'd see from a static disassembler fromPython's dis module. In particular, the STORE_NAMEinstructions show the value that is store, e.g. '2' at instructionoffset 4 into name x. Similarly INPLACE_POWER shows the operands, 2 and 3, which is how the value8 is derived as the operand of the next instruction, STORE_NAME.
Want more like the execution stack stack and block stack in addition? Add another v:
Want to see this colorized in a terminal? Use this via trepan-xpy-x:
Suppose you have Python 2.4 bytecode (or some other bytecode) forthis, but you are running Python 3.7?
Not much has changed here, other then the fact that that in after 3.6 instructions are two bytes instead of 1- or 3-byte instructions.
The above examples show straight-line code, so you see all of the instructions. But don't confuse this with a disassembler like pydisasm from xdis.The below example, with conditional branching example makes this more clear:
Want even more status and control? See trepan-xpy.
Status:
Currently bytecode from Python versions 3.7 - 3.2, and 2.7 - 2.4 aresupported. Extending to 3.8 and beyond is on hold until there is moreinterest, I get help, I need or there is or funding.
Byterun, from which this was based on, is awesome. But it cheats insubtle ways.
Want to write a very small interpreter using CPython?
This cheats in kind of a gross way, but this the kind of cheating goeson in Byterun in a more subtle way. As in the example above whichrelies on built-in function exec to do all of the work, Byterunrelies on various similar sorts of built-in functions to supportopcode interpretation. In fact, if the code you were interpretingwas the above, Byterun would use its built-in function for runningcode inside the exec function call, so all of the bytecode that getsrun inside code inside code would not seen for interpretation.
Also, built-in functions like exec, and other built-in modules havean effect in the interpreter namespace. So the two namespaces thenget intermingled.
One example of this that has been noted is for import. Seehttps://github.com/nedbat/byterun/issues/26. But there are otherscases as well. While we haven't addressed the import issuementioned in issue 26, we have addressed similar kinds of issues likethis.
Some built-in functions and the inpsect module require built-intypes like cell, traceback, or frame objects, and they can't use thecorresponding interpreter classes. Here is an example of this inByterun: class __init__ functions don't get traced into, becausethe built-in function __build_class__ is relied on. And__build_class__ needs a native function, not aninterpreter-traceable function. Seehttps://github.com/nedbat/byterun/pull/20.
Also Byterun is loose in accepting bytecode opcodes that is invalidfor particular Python but may be valid for another. I suppose this isokay since you don't expect invalid opcodes appearing in validbytecode. It can however accidentally or erronously appear code thathas been obtained via some sort of extraction process, when theextraction process isn't accruate.
In contrast to Byterun, x-python is more stringent what opcodes itaccepts.
Byterun needs the kind of overhaul we have here to be able to scale tosupport bytecode for more Pythons, and to be able to run bytecodeacross different versions of Python. Specifically, you can't rely onPython's dis module ifyou expect to run a bytecode other than the bytecode that theinterpreter is running, or run newer 'wordcode' bytecode on a'byte'-oriented byteocde, or vice versa.
In contrast, x-python there is a clear distinction between theversion being interpreted and the version of Python that isrunning. There is tighter control of opcodes and an opcode'simplementation is kept for each Python version. So we'll warn earlywhen something is invalid. You can run bytecode back to Python 2.4using Python 3.7 (largely), which is amazing give that 3.7's nativebyte code is 2 bytes per instruction while 2.4's is 1 or 3 bytes perinstruction.
The 'largely' part is, as mentioned above, because the interpreter hasalways made use of Python builtins and libraries, and for the mostpart these haven't changed very much. Often, since many of theunderlying builtins are the same, the interpreter can (and does) makeuse interpreter internals. For example, built-in functions likerange() are supported this way.
So interpreting bytecode from a newer Python release than the releasethe Python interpreter is using, is often doable too. Even thoughPython 2.7 doesn't support keyword-only arguments or format strings,it can still interpret bytecode created from using these constructs.
That's possible here because these specific features are moresyntactic sugar rather than extensions to the runtime. For example,format strings basically map down to using the format() functionwhich is available on 2.7.
But new features like asynchronous I/O and concurrency primitives are notin the older versions. So those need to be simulated, and that too is apossibility if there is interest or support.
You can run many of the tests that Python uses to test itself, and Ido! And most of those work. Right now this program works best on Python up to3.4 when life in Python was much simpler. It runs over 300 in Python'stest suite for itself without problems. For Python 3.6 the numberdrops down to about 237; Python 3.7 is worse still.
History
This is a fork of Byterun. which is a pure-Python implementation ofa Python bytecode execution virtual machine. Ned Batchelder startedit (based on work from Paul Swartz) to get a better understanding ofbytecodes so he could fix branch coverage bugs in coverage.py.
Release historyRelease notifications | RSS feed
1.3.5
1.3.4
1.3.3
1.3.2
1.3.1
1.3.0 yanked
1.2.1
1.2.0
1.1.0
1.0.1
1.0.0 yanked
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size x_python-1.3.5-py2.7.egg (199.9 kB) | File type Egg | Python version 2.7 | Upload date | Hashes |
Filename, size x_python-1.3.5-py2-none-any.whl (95.7 kB) | File type Wheel | Python version py2 | Upload date | Hashes |
Filename, size x_python-1.3.5-py3.2.egg (202.7 kB) | File type Egg | Python version 3.2 | Upload date | Hashes |
Filename, size x_python-1.3.5-py3.3.egg (207.0 kB) | File type Egg | Python version 3.3 | Upload date | Hashes |
Filename, size x_python-1.3.5-py3.4.egg (204.2 kB) | File type Egg | Python version 3.4 | Upload date | Hashes |
Filename, size x_python-1.3.5-py3.5.egg (203.5 kB) | File type Egg | Python version 3.5 | Upload date | Hashes |
Filename, size x_python-1.3.5-py3.6.egg (200.6 kB) | File type Egg | Python version 3.6 | Upload date | Hashes |
Filename, size x_python-1.3.5-py3.7.egg (200.7 kB) | File type Egg | Python version 3.7 | Upload date | Hashes |
Filename, size x_python-1.3.5-py3-none-any.whl (95.7 kB) | File type Wheel | Python version py3 | Upload date | Hashes |
Filename, size x-python-1.3.5.tar.gz (146.0 kB) | File type Source | Python version None | Upload date | Hashes |
Hashes for x_python-1.3.5-py2.7.egg
Algorithm | Hash digest |
---|---|
SHA256 | 604dc4ea30990c9cfe86a1adb93b1e3e3e35b2bc434c551deb2fe3157363891c |
MD5 | b06e2e4e7e818e0f82de37a8b6498a2e |
BLAKE2-256 | 15fbc807a592526995c1c2692cda08ccf634870f88ec56139f89cef446ff6007 |
Released:
Python cross-version byte-code interpeter
Project description
x-python
This is a CPython bytecode interpreter written Python.
You can use this to:
- Learn about how the internals of CPython works since this models that
- Experiment with additional opcodes, or ways to change the run-time environment
- Use as a sandboxed environment for trying pieces of execution
- Have one Python program that runs multiple versions of Python bytecode.
- Use in a dynamic fuzzer or in coholic execution for analysis
The ability to run Python bytecode as far back as 2.4 from Python 3.7I find pretty neat. (Even more could easily be added).
Also, The sandboxed environment in a debugger I findinteresting. (Note: currently environments are not sandboxed thatwell, but I am working towards that.)
Since there is a separate execution, and traceback stack,inside a debugger you can try things out in the middle of a debugsession without effecting the real execution. On the other hand if asequence of executions works out, it is possible to copy this (undercertain circumstances) back into CPython's execution stack.
Going the other way, I have hooked in trepan3k into this interpreter so youhave a pdb/gdb like debugger also with the ability to step bytecodeinstructions.
To experiment with faster ways to support trace callbacks such asthose used in a debugger. In particular added an instruction tosupport fast breakpoints and breakpointing on a particular instructionthat doesn't happen to be on a line boundary. I believe this couldcould and should be ported back to CPython and there would be benefit.(Python 3.8 supports the ability to save additional frame information whichis where the original opcode is stored. It just needs the BRKPT opcode)
Although this is far in the future, suppose you to add a racedetector? It might be easier to prototype it in Python here. (Thisassumes the interpreter supports threading well, I suspect it doesn't)
Another unexplored avenue implied above is mixing interpretation anddirect CPython execution. In fact, there are bugs so this happensright now, but it will be turned into a feature. Some functions orclasses you may want to not run under a slow interpreter while othersyou do want to run under the interpreter.
Examples:
What to know instructions get run when you write some simple code?Try this:
Option -c is the same as Python's flag (program passed in as string)and -v is also analogus Python's flag. Here, it shows the bytecodeinstructions run.
Note that the disassembly above in the dynamic trace above gives alittle more than what you'd see from a static disassembler fromPython's dis module. In particular, the STORE_NAMEinstructions show the value that is store, e.g. '2' at instructionoffset 4 into name x. Similarly INPLACE_POWER shows the operands, 2 and 3, which is how the value8 is derived as the operand of the next instruction, STORE_NAME.
Want more like the execution stack stack and block stack in addition? Add another v:
Want to see this colorized in a terminal? Use this via trepan-xpy-x:
Suppose you have Python 2.4 bytecode (or some other bytecode) forthis, but you are running Python 3.7?
Not much has changed here, other then the fact that that in after 3.6 instructions are two bytes instead of 1- or 3-byte instructions.
The above examples show straight-line code, so you see all of the instructions. But don't confuse this with a disassembler like pydisasm from xdis.The below example, with conditional branching example makes this more clear:
Want even more status and control? See trepan-xpy.
Status:
Currently bytecode from Python versions 3.7 - 3.2, and 2.7 - 2.4 aresupported. Extending to 3.8 and beyond is on hold until there is moreinterest, I get help, I need or there is or funding.
Byterun, from which this was based on, is awesome. But it cheats insubtle ways.
Want to write a very small interpreter using CPython?
This cheats in kind of a gross way, but this the kind of cheating goeson in Byterun in a more subtle way. As in the example above whichrelies on built-in function exec to do all of the work, Byterunrelies on various similar sorts of built-in functions to supportopcode interpretation. In fact, if the code you were interpretingwas the above, Byterun would use its built-in function for runningcode inside the exec function call, so all of the bytecode that getsrun inside code inside code would not seen for interpretation.
Also, built-in functions like exec, and other built-in modules havean effect in the interpreter namespace. So the two namespaces thenget intermingled.
One example of this that has been noted is for import. Seehttps://github.com/nedbat/byterun/issues/26. But there are otherscases as well. While we haven't addressed the import issuementioned in issue 26, we have addressed similar kinds of issues likethis.
Some built-in functions and the inpsect module require built-intypes like cell, traceback, or frame objects, and they can't use thecorresponding interpreter classes. Here is an example of this inByterun: class __init__ functions don't get traced into, becausethe built-in function __build_class__ is relied on. And__build_class__ needs a native function, not aninterpreter-traceable function. Seehttps://github.com/nedbat/byterun/pull/20.
Also Byterun is loose in accepting bytecode opcodes that is invalidfor particular Python but may be valid for another. I suppose this isokay since you don't expect invalid opcodes appearing in validbytecode. It can however accidentally or erronously appear code thathas been obtained via some sort of extraction process, when theextraction process isn't accruate.
In contrast to Byterun, x-python is more stringent what opcodes itaccepts.
Byterun needs the kind of overhaul we have here to be able to scale tosupport bytecode for more Pythons, and to be able to run bytecodeacross different versions of Python. Specifically, you can't rely onPython's dis module ifyou expect to run a bytecode other than the bytecode that theinterpreter is running, or run newer 'wordcode' bytecode on a'byte'-oriented byteocde, or vice versa.
In contrast, x-python there is a clear distinction between theversion being interpreted and the version of Python that isrunning. There is tighter control of opcodes and an opcode'simplementation is kept for each Python version. So we'll warn earlywhen something is invalid. You can run bytecode back to Python 2.4using Python 3.7 (largely), which is amazing give that 3.7's nativebyte code is 2 bytes per instruction while 2.4's is 1 or 3 bytes perinstruction.
The 'largely' part is, as mentioned above, because the interpreter hasalways made use of Python builtins and libraries, and for the mostpart these haven't changed very much. Often, since many of theunderlying builtins are the same, the interpreter can (and does) makeuse interpreter internals. For example, built-in functions likerange() are supported this way.
So interpreting bytecode from a newer Python release than the releasethe Python interpreter is using, is often doable too. Even thoughPython 2.7 doesn't support keyword-only arguments or format strings,it can still interpret bytecode created from using these constructs.
That's possible here because these specific features are moresyntactic sugar rather than extensions to the runtime. For example,format strings basically map down to using the format() functionwhich is available on 2.7.
But new features like asynchronous I/O and concurrency primitives are notin the older versions. So those need to be simulated, and that too is apossibility if there is interest or support.
You can run many of the tests that Python uses to test itself, and Ido! And most of those work. Right now this program works best on Python up to3.4 when life in Python was much simpler. It runs over 300 in Python'stest suite for itself without problems. For Python 3.6 the numberdrops down to about 237; Python 3.7 is worse still.
History
This is a fork of Byterun. which is a pure-Python implementation ofa Python bytecode execution virtual machine. Ned Batchelder startedit (based on work from Paul Swartz) to get a better understanding ofbytecodes so he could fix branch coverage bugs in coverage.py.
Release historyRelease notifications | RSS feed
1.3.5
1.3.4
1.3.3
1.3.2
1.3.1
1.3.0 yanked
1.2.1
1.2.0
1.1.0
1.0.1
1.0.0 yanked
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size x_python-1.3.5-py2.7.egg (199.9 kB) | File type Egg | Python version 2.7 | Upload date | Hashes |
Filename, size x_python-1.3.5-py2-none-any.whl (95.7 kB) | File type Wheel | Python version py2 | Upload date | Hashes |
Filename, size x_python-1.3.5-py3.2.egg (202.7 kB) | File type Egg | Python version 3.2 | Upload date | Hashes |
Filename, size x_python-1.3.5-py3.3.egg (207.0 kB) | File type Egg | Python version 3.3 | Upload date | Hashes |
Filename, size x_python-1.3.5-py3.4.egg (204.2 kB) | File type Egg | Python version 3.4 | Upload date | Hashes |
Filename, size x_python-1.3.5-py3.5.egg (203.5 kB) | File type Egg | Python version 3.5 | Upload date | Hashes |
Filename, size x_python-1.3.5-py3.6.egg (200.6 kB) | File type Egg | Python version 3.6 | Upload date | Hashes |
Filename, size x_python-1.3.5-py3.7.egg (200.7 kB) | File type Egg | Python version 3.7 | Upload date | Hashes |
Filename, size x_python-1.3.5-py3-none-any.whl (95.7 kB) | File type Wheel | Python version py3 | Upload date | Hashes |
Filename, size x-python-1.3.5.tar.gz (146.0 kB) | File type Source | Python version None | Upload date | Hashes |
Hashes for x_python-1.3.5-py2.7.egg
Algorithm | Hash digest |
---|---|
SHA256 | 604dc4ea30990c9cfe86a1adb93b1e3e3e35b2bc434c551deb2fe3157363891c |
MD5 | b06e2e4e7e818e0f82de37a8b6498a2e |
BLAKE2-256 | 15fbc807a592526995c1c2692cda08ccf634870f88ec56139f89cef446ff6007 |
Hashes for x_python-1.3.5-py2-none-any.whl
Algorithm | Hash digest |
---|---|
SHA256 | d8777990d82a3bbdcc0df4219230f98609c3d25e70ba7f3267b166a41745a67b |
MD5 | d75688c2d0138e1077f017333f97e5c3 |
BLAKE2-256 | 23e7f52c8783215b88b2fe6ea5b4e4ed81b70fd6c80f28223cea1ea06af83936 |
Hashes for x_python-1.3.5-py3.2.egg
Best Python Interpreter
Algorithm | Hash digest |
---|---|
SHA256 | e0465d2f08321dd1891950ced32ba7a1757e09b7463e09b8164263bbeb367a75 |
MD5 | 67819ecdbecf20ddfea6cc310c731eaf |
BLAKE2-256 | 0890de3f533b6c2872010663794df6b936cb2446eba139dc82c4ed08699a1ff6 |
Hashes for x_python-1.3.5-py3.3.egg
Interpreter For Python
Algorithm | Hash digest |
---|---|
SHA256 | 4becf894f4a1920a648b78583fa37d8e180fb249e8f1f1e664291382568bb0f5 |
MD5 | 005e21ba88c25edf73f519b9a98ab5c0 |
BLAKE2-256 | e0109bb507f9baa205f57725496e69916dc05e8d0c17ea362b85210a97bec710 |
Hashes for x_python-1.3.5-py3.4.egg
Algorithm | Hash digest |
---|---|
SHA256 | 198962db8b3b3fd46345e822808bb0042f5a4205254af92545f9be7be54802a1 |
MD5 | af1350a3ceab90362c0d4905a91d2845 |
BLAKE2-256 | f09f43d0a2096b68c0b2d1daddbcd58fe11492a92bbea16435823d96d613d834 |
Hashes for x_python-1.3.5-py3.5.egg
Algorithm | Hash digest |
---|---|
SHA256 | 0fa05910bf95d346edefcf05bc2a5a9ff2416102d8c5f97343cda0c0394cc128 |
MD5 | 1b2b0859664cd8fb3fc744d30cd2798f |
BLAKE2-256 | 3582cca17e2ec81099bf6720b17bc8aef61272d71cb1db991d0bcb09e1c9d051 |
Hashes for x_python-1.3.5-py3.6.egg
Algorithm | Hash digest |
---|---|
SHA256 | 016aaacbe362ee4228a9bc8829cba43a5f2064ba28ed92f94762b3a3b5fbc496 |
MD5 | e6e2013a716bcd1f053dfe5fb3948821 |
BLAKE2-256 | 60dcb1849348ed342146ce83b8097fd25c850e84636230d0443a57e3caaf1025 |
Python 3 Interpreter Windows
Hashes for x_python-1.3.5-py3.7.egg
Algorithm | Hash digest |
---|---|
SHA256 | 0bbef64362b70bc450257c73c5855c99d85c27b70b3c810e76ada7f14163e6e9 |
MD5 | 7d6633b087c4f76b4b8ce334a8a21d8f |
BLAKE2-256 | 4389612dc24df747cc1fc2cf9f65449fa0664f26e0c997a4bfbfebbaa103ae16 |
Hashes for x_python-1.3.5-py3-none-any.whl
Algorithm | Hash digest |
---|---|
SHA256 | b4d93840fea1f4355321a72b4bdeb95a0b8c8941594259334d3e5fe6c660c3d4 |
MD5 | 7a3782dc8f2a8fa003715f65efdf03f3 |
BLAKE2-256 | cbf4408d398af5e77190b480f5040ac952f718ed7ba28769b28f8a1418cd5b3d |
Python 2 Interpreter
CloseHashes for x-python-1.3.5.tar.gz
Algorithm | Hash digest |
---|---|
SHA256 | e1985652e25276fb84b1d22d34447414a3f959ebc9c2802be7f1b46400bb5678 |
MD5 | fa3ed3c3efc7da740a8412fc78e7aa0f |
BLAKE2-256 | 199991810e582911b32d89e35f87214579430228a5bebbdb59f95bffab7058ac |