Comments (7)
Yep, import is not yet functional :) This was pretty much the next thing on my list to get working, since I know it's very important, and I can't really call it Micro Python if it ain't got import/modules.
There are no road blocks, I just need time to implement it. The compiler emits correct import code, all the framework is there to run "import" when needed, and module-level variables (dictionary) is already being used for the main script.
from micropython.
I'm hoping to help with this issue by doing the following. Can you guys validate if this is a good idea - or if the import module for micropython will take care of it ?
It makes a minmal set of python code by copying and stripping unused functions out of imported modules.
First - it processes the tree of imports from all python files.
Second - it copies these files to a new subdirectory, renames them and their respective imports so the new files are loaded instead of the original modules.
Third - it removes all unused code from these files.
The end result is a minimal python setup which will have the smallest memory footprint.
It is one way to solve the problem, but the import preprocessor could also strip out unused functions (I think).
Is this a useful thing to do ?
Its here: https://github.com/Neon22/python-flavin
from micropython.
@dpgeorge: Good plan, thanks!
from micropython.
@Neon22: Regardless of how uPy module system will work, I guess your tool is useful. I hope you tried to search prior art to avoid reinventing a wheel (but I personally never heard of such tool for Python). Also I hope you keep in mind that in general case it's not possible to do what you want in a dynamic language ;-). Because for example you can do obj.getattr("do_" + method)(). So, I hope you'll balance automation and heuristics vs user configurability. Java's ProGuard as used e.g. by Android can be example of production-quality tool which does this stuff. All in all, this is worth a separate space to discuss (yeah, we'll need forum in some time ;-). Hope someone indeed helps Damien with that to let him do hacking, which noone else can do ;-).)
from micropython.
@Neon22: the upython code will not do any of this. It will act as normal CPython does and read in the right Python script, compile/run it, and assign global names as appropriate. Any minification, as you suggest, would need to be done by a preprocessor. So your tool would be useful, but I wouldn't classifiy it as a priority.
from micropython.
Basic import is now working. Still some things to fix up so I'll keep this issue open.
from micropython.
Basic import indeed works, so let's close this and open more feature-detailed tickets as needed.
from micropython.
Related Issues (20)
- rp2: Pico W, hang setting up board LED HOT 5
- Unable to print unicode characters when running repl with mpremote
- [RP2] Not getting serial device with 1.23 (good with prior versions) HOT 3
- round() returns incorrect results HOT 6
- docs: calling a viper function inside another viper function HOT 7
- docs: viper and garbage collection HOT 2
- const declaration: constancy is only enforced within a module HOT 8
- asm: inline assembler: directive "data" for all the micros HOT 1
- docs: Document limited numerical precision HOT 2
- esp32.wake_on_ext0 not workingon esp32s2 HOT 1
- ISR latency affected by BLE, unable to interface with 2kHz sample rate ADC. HOT 2
- Include a WASM interpreter as part of micropython or its standard library? HOT 3
- Renesas-RA: Pin-IRQ does not behave as expected. HOT 5
- MQTTS fail on ESP32-S3 but works in ESP32
- Cannot instantiate FrameBuffer from a bytes object HOT 9
- Build errors when building RPI_PICO for debug HOT 1
- mpremote cannot cat with recent MP on pyboard HOT 4
- asyncio module seems missing in self built firmware for ESP8266 board HOT 6
- nimble compile errors HOT 2
- ESP32-S3 Linking errors HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from micropython.