Comparison of overheads of micropython operations

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
stijn
Posts: 735
Joined: Thu Apr 24, 2014 9:13 am

Re: Comparison of overheads of micropython operations

Post by stijn » Sat Feb 17, 2018 12:53 pm

running against a stock firmware image
I'm fairly sure there are also a number of core types present in stock firmware which have their own attr implementation, possibly making them behave differently with regards to property performance in comparision with Python classes.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Comparison of overheads of micropython operations

Post by pythoncoder » Sun Feb 18, 2018 8:43 am

deshipu wrote:
Sat Feb 17, 2018 12:47 pm
I don't think you should be choosing the programming constructs in your program based on microsecond differences in execution time...
I agree with all of that. In spades :D

In terms of practical experience developing MicroPython applications (and elsewhere) the key is to identify the section of code which presents the bottleneck. Often it's quite small, maybe a single function or method. You can then pull out all the stops to optimise that: cache bound variables in locals, try different constructs, use Viper, measure the outcome of every change. As you say, if it's still too slow use the inline assembler.

If the code is to be maintained by others comment the hairy section thoroughly.

The bulk of the code should be written for clarity and ease of maintenance.
Peter Hinch
Index to my micropython libraries.

Post Reply