4 ms·
I actually embarked on a similar Python VM called Ninia [1] awhile back, but shelved it as other projects became more important. Ninia supports multiple threads
by jvilk 10y ago
I actually embarked on a similar Python VM called Ninia [1] awhile back, but shelved it as other projects became more important. Ninia supports multiple threads and preempts execution to give the browser breathing space, just like my JVM in JavaScript, DoppioJVM [2].
One of the challenges of Python is its objects are quite complex/ad-hoc, and can be overridden by the user. I mapped out [3] how I wanted to map Python objects to JavaScript objects, but never had the time to implement it fully. (That document covers Python 2.7; I'm sure there are differences for 3.) It looks like this project has a lot of work to do if it wants to have parity with a native Python VM! But that's part of the fun of writing these things.
Best of luck on the VM! If you need a file system to plug into the VM for loading modules/implementing the FS API, do check out my BrowserFS library [4], which is currently in use at the Internet Archive [5] and is also used in Ninia/DoppioJVM. You can also cop things from Ninia, as it is MIT licensed.
Oh yeah, and if you need a Python compiler/parser, you can simply run the PyPy interpreter's parser+compiler [6] in your intepreter once it is reasonably complete. It is written in 100% Python!
[1] https://github.com/plasma-umass/ninia https://github.com/plasma-umass/ninia
[2] https://github.com/plasma-umass/doppio https://github.com/plasma-umass/doppio
[3] https://github.com/plasma-umass/Ninia/wiki/Mapping-Python-Objects-to-JavaScript-Objects https://github.com/plasma-umass/Ninia/wiki/Mapping-Python-Ob...
[4] https://github.com/jvilk/browserfs https://github.com/jvilk/browserfs
[5] http://ascii.textfiles.com/archives/4924 http://ascii.textfiles.com/archives/4924
[6] https://pypy.readthedocs.org/en/latest/interpreter.html https://pypy.readthedocs.org/en/latest/interpreter.html
- koehlma 10y agoCool, I will have a look through your code and BrowserFS seems especially useful to me.