how to set optimization level for a required frozen module #18256
-
|
I'm trying to apply optimization level 3 to the typing module in my MicroPython project using a manifest file, but I'm not observing any reduction in size with or without the Here's my manifest file: include("$(PORT_DIR)/variants/manifest.py")
include("$(MPY_DIR)/extmod/asyncio")
# typing related modules
require("typing", opt=3)
# 3-4 similar modules I have added some logging to and I do not see the opt level appearing for the typing module. It would seem logical that the Ive also tried the same/similar in a Alternatives: Rewrite this as a package , loosing the simplicity of reference by name: package("$(MPY_LIB_DIR)/python-stdlib/typing", opt=3)The only option I get to work is by setting -O3 for the entire project ( quite a substantial size improvement BTW) but that is not my intent at this time. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
After a good night's sleep I was able to figure out how to pass options from one manifest to another. It appears this is not yet documented in docs 📗 Example on how to use this that also allow different options to be passed to different modules/requires: board/variant manifest.py: require(
"bundle-typing",
# opt_level=2, # defaults to 3
)bundle-typing/manifest.py: options.defaults(opt_level=3, extensions=False)
require("__future__", opt_level=options.opt_level)
require("typing", opt_level=options.opt_level)
require("abc", opt_level=options.opt_level)typing/manifest.py: # default to opt_level 3 for minimal firmware size
options.defaults(opt_level=3)
module("typing.py", opt=options.opt_level) |
Beta Was this translation helpful? Give feedback.
After a good night's sleep I was able to figure out how to pass options from one manifest to another.
See manifestfile.py:
includehas this documentedIt appears this is not yet documented in docs 📗
Example on how to use this that also allow different options to be passed to different modules/requires:
board/variant manifest.py:
bundle-typing/manifest.py:
typing/manifest.py:
# default to opt_level …