Hi,
I am curious to know the differences/advantages/disadvantages of Frozen Bytecode (.mpy) in firmware (as a module) vs in the file system.
Thank you in advance.
Frozen Bytecode (.mpy) in firmware vs in file system
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Frozen Bytecode (.mpy) in firmware vs in file system
Putting a .mpy file in the filesystem removes the need for the device to compile the file: this can be a problem with large sourcefiles and devices with little RAM. However doing this doesn't reduce the RAM used at runtime as the bytecode has to be pulled into RAM for execution.
Compiling the code as frozen bytecode enables the bytecode to be run directly from flash (if the CPU hardware supports this). There can be a dramatic reduction in runtime RAM usage.
The symptom of the compiler running out of RAM is a memory error when you import a Python source module at the REPL.
Compiling the code as frozen bytecode enables the bytecode to be run directly from flash (if the CPU hardware supports this). There can be a dramatic reduction in runtime RAM usage.
The symptom of the compiler running out of RAM is a memory error when you import a Python source module at the REPL.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.