Optimising Python speed tutorial

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
User avatar
pythoncoder
Posts: 5272
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Optimising Python speed tutorial

Post by pythoncoder » Thu Feb 11, 2016 10:54 am

For those who don't follow Github I've written a tutorial planned for eventual inclusion in the official docs. At this stage it's very much a draft and is doubtless littered with typos. Comments on the content are invited, especially if there are factual errors or useful techniques I've omitted. It can be read here: http://hinch.me.uk/html/reference/speed_python.html
Peter Hinch

User avatar
bmarkus
Posts: 111
Joined: Tue Oct 21, 2014 5:58 am

Re: Optimising Python speed tutorial

Post by bmarkus » Thu Feb 11, 2016 11:16 am

Great article, thanks!
Tiny Core Linux (piCore) developer
HAM radio call: HA5DI (Béla)

User avatar
dhylands
Posts: 3668
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Optimising Python speed tutorial

Post by dhylands » Thu Feb 11, 2016 1:47 pm

Excellent.

The second to the last sentence in the Garbage Collection section doesn't make sense (well really just the bcomes at the end):
Finally performing collections regularly can reduce fragmentation in the heap bcomes.

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

Re: Optimising Python speed tutorial

Post by pythoncoder » Thu Feb 11, 2016 1:56 pm

Thanks, Dave. Now fixed.
Peter Hinch

User avatar
Roberthh
Posts: 2754
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Optimising Python speed tutorial

Post by Roberthh » Thu Feb 11, 2016 8:15 pm

Hello @pythoncoder, that is really a good text, and it is a big support for everyone trying to code "at the bus". And I am definitely the wrong person for see typos. Maybe Damien or someone else from the core team could have a look at it, if something would have to be amended, especially about language extensions of the viper emitter.

User avatar
marfis
Posts: 206
Joined: Fri Oct 31, 2014 10:29 am
Location: Zurich / Switzerland

Re: Optimising Python speed tutorial

Post by marfis » Fri Feb 12, 2016 7:23 am

A really useful and competent writeup. Thanks a lot for sharing.

folke
Posts: 8
Joined: Thu Jun 04, 2015 3:26 pm

Re: Optimising Python speed tutorial

Post by folke » Fri Feb 12, 2016 4:33 pm

Well, I can only second this. I have really missed this kind of good documentation.

So I feel a little uneasy to mention one small correction: Time is measured in seconds and the SI-unit is spelled with lower case "s". (The upper case "S" is used for Siemens [= 1/ohm]). So in the Python code examples, that are so good and welcome, it is a little disturbing to see the unit for time as "mS". For me this looks like "milli Siemens".

I have for a long time hesitated to mention this small thing, but since I'm sure a lot of people will enjoy pythoncoder's documentation and Python scripts, I decided to suggest this minute correction after all.

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: Optimising Python speed tutorial

Post by pfalcon » Sun Feb 14, 2016 11:16 am

Great work, pythoncoder! And while this fits wll with "Development" subforum, I'm sure more wider exposure via "General" will only help, so moving it there.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

Post Reply