Understanding Inside of Micropython

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
User avatar
hadi
Posts: 9
Joined: Wed Feb 06, 2019 3:43 pm

Understanding Inside of Micropython

Post by hadi » Thu Mar 07, 2019 11:07 am

Hi everybody
I need to understand micropython internal source code(especially the mechanism of VM working).
for this I have searched a lot about any documents that related to micropython internal working but the more I try the less I get result.
since I want to know is there any document about micropython internal or not? or how can i get some good information about micropython virtual machine?
thanks

jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

Re: Understanding Inside of Micropython

Post by jickster » Fri Mar 08, 2019 6:10 pm

There is no document about internals.

The documentation for uPy is not even up to date.

You’re gonna have to read the code.


Sent from my iPhone using Tapatalk Pro

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: Understanding Inside of Micropython

Post by pfalcon » Fri Mar 08, 2019 10:05 pm

MicroPython VM works in the same way as any other VM. And there're tons of documentation about how VMs work generated by this civilization. Once you know those, particular details are indeed can be looked up on spot in the source code.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

oclyke
Posts: 18
Joined: Tue Mar 19, 2019 4:55 am

Re: Understanding Inside of Micropython

Post by oclyke » Tue Mar 19, 2019 7:16 am

hadi, I would agree with jickster and pfalcon - the surefire way to learn about uPython is to read the code. I'll add that if you're like me and tend to get caught up in the details that it is important to take it in small chunks. For example when you're trying to understand the garbage collector don't worry about what the bytes in the allocated blocks _mean_ but just what they do in C.

As for the VM itself I have yet to even find any definition of the bytecode that is used - I've felt that it's enough for me to assume that it 'is' CPython bytecode.

Here are some resources that I found helpful:
http://www.aosabook.org/en/500L/a-pytho ... ython.html
http://craftinginterpreters.com/

As a parting thought, why do you need to learn about the VM? If there's a specific reason then it might turn out that you can just leave it as a black box -- however if you're just curious then by all means dive in and see what it does!

Post Reply