Page 1 of 1

Understanding Inside of Micropython

Posted: Thu Mar 07, 2019 11:07 am
by hadi
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

Re: Understanding Inside of Micropython

Posted: Fri Mar 08, 2019 6:10 pm
by jickster
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

Re: Understanding Inside of Micropython

Posted: Fri Mar 08, 2019 10:05 pm
by pfalcon
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.

Re: Understanding Inside of Micropython

Posted: Tue Mar 19, 2019 7:16 am
by oclyke
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!