Creating a new language in a Python virtual machine

Is it possible to create a new language for a Python virtual machine? I read http://late.am/post/2012/03/26/exploring-python-code-objects , where a blogger discusses Python code objects. In it, he discusses the disassembly of a code object into bytecode and what the characters mean in it.

It made me think there might be alternative ways to build this bytecode. I was wondering how to create an isolated language in Python bytecode so that Python can load it. Using Python itself for the sandbox seems almost unusable, but that seems to make the way for another implementation language.

Where would I start if I wanted to continue this venture? What could be a better approach, and where can I find more on other approaches?

+2
source share
2 answers

Why luck is tough once hacked together a script that would compile Ruby code into Python bytecode. I remember that it worked well for simple ruby ​​scripts. You can look at the sources to find out how he did it.

EDIT . What he does is let Ruby VM generate Ruby byte code than translate that byte code into Python. It may be interesting to see how Python bytecode is assembled :)

+3
source

Source: https://habr.com/ru/post/1536113/


All Articles