What functions - and what does each do - do I need to call to "reset" the execution environment?
Let's say I've executed a bunch of REPL lines and now I want to execute a frozen script; how do I make the execution environment pristine?
1. MP_STATE_VM
2. the heap
Do I zero-out these structures? mp_init()?
how to re-init the Python execution environment
Re: how to re-init the Python execution environment
Do you have a reason to avoid the following invocation...
...or are you just curious if it cleanup can be done without a reset by manipulating in-memory structures?
My suspicion is there are implicitly aspects of the python language, such as imports being a one-way street (once imported, entries in the symbol table always there) which require a reset of the interpreter to really clean up. This is what the reset() function is intended for.
Note, a soft reset via machine.reset() is not quite the same as a hard reset which resets all the hardware subsystems of the board, not just the interpreter. This is an even more 'pristine' starting point. A hard reset can be done by power-cycling (unplugging and replugging USB power to a board) or potentially by pulsing your own reset pin, with a wire from a GPIO to RST as described [here](viewtopic.php?t=3582#p20789)
Code: Select all
import machine
machine.reset()
My suspicion is there are implicitly aspects of the python language, such as imports being a one-way street (once imported, entries in the symbol table always there) which require a reset of the interpreter to really clean up. This is what the reset() function is intended for.
Note, a soft reset via machine.reset() is not quite the same as a hard reset which resets all the hardware subsystems of the board, not just the interpreter. This is an even more 'pristine' starting point. A hard reset can be done by power-cycling (unplugging and replugging USB power to a board) or potentially by pulsing your own reset pin, with a wire from a GPIO to RST as described [here](viewtopic.php?t=3582#p20789)