Replies: 1 comment 2 replies
-
If the file is a .py script, it will be loaded into memory so that the compiler can compile it to bytecode. This applies whatever method you use. The RAM used by the source will then be reclaimed with the bytecode being run from RAM. The compilation phase may be skipped by precompiling, in which case the bytecode will be loaded directly into RAM. To run from flash with near zero RAM usage you need frozen bytecode. It is possible to reload a module (but maybe you already know this): import gc
import sys
def reload(mod):
mod_name = mod.__name__
del sys.modules[mod_name]
gc.collect()
__import__(mod_name) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I wanted to ask what is the recommended option to run files form the filesystem?
I found those three options:
execfile(fn)
is deprecated in normal Python and requires a compiler flagexec(open(...).read())
recommended alternative to first option in normal Python but seems like it would load the full file into memoryimport myfile
does not run if name == "main" and requires more work to run a second time as you first have to remove the moduleBeta Was this translation helpful? Give feedback.
All reactions