What's mean 'opt=3' in manifest.py for frozen ?

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
User avatar
water
Posts: 75
Joined: Sun Sep 24, 2017 9:16 am

What's mean 'opt=3' in manifest.py for frozen ?

Post by water » Tue Sep 01, 2020 11:15 pm

In some manifest.py file, likes:

Code: Select all

freeze(
    "..",
    (
        "xx/xxx.py",
        ...
    ),
    opt=3,
)
What's mean

Code: Select all

opt=3

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: What's mean 'opt=3' in manifest.py for frozen ?

Post by jimmo » Wed Sep 02, 2020 4:43 am

water wrote:
Tue Sep 01, 2020 11:15 pm
What's mean

opt=3
It sets mp_optimise_value, which with a value of 3 will remove line number information from the bytecode (smaller firmware) and prevent emitting any code for "assert" statements.

User avatar
water
Posts: 75
Joined: Sun Sep 24, 2017 9:16 am

Re: What's mean 'opt=3' in manifest.py for frozen ?

Post by water » Thu Sep 03, 2020 6:10 am

Thanks.
It looks like not a python script.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: What's mean 'opt=3' in manifest.py for frozen ?

Post by jimmo » Thu Sep 03, 2020 6:23 am

water wrote:
Thu Sep 03, 2020 6:10 am
It looks like not a python script.
Not sure I follow sorry, what doesn't look like a python script?

User avatar
water
Posts: 75
Joined: Sun Sep 24, 2017 9:16 am

Re: What's mean 'opt=3' in manifest.py for frozen ?

Post by water » Thu Sep 03, 2020 7:40 am

Which language use manifest.py ?

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: What's mean 'opt=3' in manifest.py for frozen ?

Post by jimmo » Thu Sep 03, 2020 8:07 am

water wrote:
Thu Sep 03, 2020 7:40 am
Which language use manifest.py ?
It's Python.

The example you provided (uasyncio/manifest.py) is a one-line Python program that calls the "freeze" function.

You can think of is as just regular Python (which it is, it's run by CPython) just with functions like "freeze" provided as globals. (Same way Python provides functions like "print").

bradstew
Posts: 41
Joined: Thu Nov 29, 2018 9:29 pm

Re: What's mean 'opt=3' in manifest.py for frozen ?

Post by bradstew » Thu Sep 09, 2021 9:34 pm

so 'opt=3' prevents emitting any code for "assert" statements. So if I am using assert, I should set it to another value?
Where can i find a list of the options?


Post Reply