Skip to content

Support main.mpy/code.mpy files to execute at startup. #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tdicola opened this issue Jun 3, 2017 · 2 comments
Closed

Support main.mpy/code.mpy files to execute at startup. #145

tdicola opened this issue Jun 3, 2017 · 2 comments

Comments

@tdicola
Copy link

tdicola commented Jun 3, 2017

It looks like right now main code execute at boot has to be a pure python .py file. This is tricky though since pure python code has a significant memory overhead during parsing. Beyond about 100 lines of code in a main.py it becomes impossible to import a few modules and run code. An easy way around this is switching to .mpy files that are processed ahead of time to reduce their size and parsing memory usage. Let's see if we can support main.mpy/code.mpy files execute on boot for those cases where users need the most memory possible.

@tannewt
Copy link
Member

tannewt commented Jun 5, 2017

Would you mind posting the main.py file? I'm hesitant to support mpy'd mains because they are opaque files. I'd rather have it always possible to read main and instead factor out stuff into mpy'd libraries.

@tannewt
Copy link
Member

tannewt commented Jun 7, 2017

I believe this is less of an issue now. I believe @tdicola was using ampy to load main.py which copies all of the file contents into memory before parsing. Saving main.py to the internal storage first will mitigate this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants