Description
Summary
Adding support for CPython bytecode will open many new possibilities for testing and using the RustPython VM.
Detailed Explanation
There are many, many projects using the CPython bytecode. If RustPython were to support it, we could ship the RustPython VM as an individual tool, integrable into existing projects. This could be very useful to the RustPython project, by generating countless new test cases for the VM, and by attracting new users and contributors.
An interesting use case is mentioned in #1760 - if the RustPython VM were to support CPython bytecode, a relatively compact WASM compilation of the VM could be distributed to allow lightweight frontend scripting with full python syntax.
Another potential use case is integrating the RustPython VM with CPython by using the frame evaluation API introduced in PEP 523. This will allow users to use CPython normally with an underlying RustPython VM. I am not very familiar with the RustPython VM but I'm sure it might offer some performance gains for specific python projects.
Drawbacks, Rationale, and Alternatives
I am not sure what would be a good way to add support for the CPython bytecode, but I think that generally there are two options:
- Create a converter. As offered in Create converters from cpython bytecode #6, it might be possible to implement a full translator between the two bytecode sets.
- Change the RustPython bytecode to match CPython's. I have no idea how hard it would be. Hopefully you guys do?
Unresolved Questions
- There are probably more cases in which an independent rusty CPython bytecode VM is useful. Any ideas?
- What is a good way to add support for CPython bytecode? Is it possible to create a converter? Is changing the current RustPython bytecode even an option?