4 ms·
Could someone in the know explain how Pycopy/MicroPython code is executed? I don't understand whether these are (bytecode) interpreters or compilers to machine
by tom_mellior 6y ago
Could someone in the know explain how Pycopy/MicroPython code is executed? I don't understand whether these are (bytecode) interpreters or compilers to machine code. Or are they both?
- andyjpb 6y ago'Pycopy can execute scripts in textual source form or from precompiled bytecode, in both cases either from an on-device filesystem or "frozen" into the executable.'
- tom_mellior 6y agoThanks, but this doesn't answer the question how it executes those scripts. I would usually interpret it to mean a bytecode interpreter, but as the sister comment explains, that would not be the full story since there is indeed native code compilation as well.
- pfalcon 6y agoThey're both. All that stuff comes from MicroPython for full disclosure. There's a bytecode VM and a rather primitive JIT. Such primitive that actually on modern designed-for-meltdown processors, bytecode VM actually runs faster than the JIT. My interest for Pycopy is exactly to work on more advanced JIT, etc. techniques, and that's one of the reason for the fork - I want to keep the foundation clean and simple enough (yet extensible). "Simple" is the foundation for "fast JIT" (because if you have to much stuff to check for, the result code will be slow).
- crazypython 6y agoDo you implement inspect.stack, metaclasses, __mro_classes__, etc.?
- pfalcon 6y agoNo, I implement a generic object-oriented language with elements of functional paradigm, amenable for small-size VM and JIT implementation, a Python dialect. Extensibility is also important goal, but of course, extensibility and JITtability conflict, so you get ('ll get) one or another. That said, I have C3 MRO (i.e. full multiple inheritance support) in the devel branch. Metaclasses, I leave to upstream (they've got to do something useful too), at least until I need them (none so far: "generic language", remember? How will I port those metaclasses to C++? Python is certainly not the only language I use). inspect.stack - no go, CPython implementation detail.