Executing scripts in a few milliseconds with MicroPython
Marwan Al-Sabbagh (~marwan) |
Command execution time can become important in a number of applications. Commands executed in command-line completion need to execute in less then 100ms or users will perceive a delay. In Shell scripting one might want to execute commands repeatedly in a for loop and fast execution times makes this more feasible.
Python is a very powerful language but has a much slower startup time compared to other interpreted languages like Perl, Lua and Bash. It can take up to 10 times longer to startup then some of these other languages.
MicroPython was written as a lean implementation of Python 3 with a small subset of the standard library mainly intended to run on microcontrollers. But it happily runs on Unix systems with excellent startup performance, making it an ideal candidate for implementing certain time sensitive commands.
This talk will:
Explain when achieving fast execution times matters and when it doesn’t.
Present two different approaches to measuring command execution time, one simple and the other more detailed and accurate.
Compare execution times of a simple set of scripts that add two numbers in an number of different interpreted languages (micropython, python3, awk, perl, lua, bash).
Present an example use case of MicroPython on Unix. Bash completion for pip install that completes the names of available packages live from a remote pypi mirror.
Demonstrate the auto completion script with pip on a local pypi mirror.
Basic understanding of running python scripts on the command line.
Details of this talk can be found on my website.
This talk was previously given at EuroPython 2017
slides on speakerdeck
video of this talk being given at EuroPython 2017
I'm a passionate Python developer living on the sunny island of Bahrain. I've been a speaker at Python conferences before and ran the Bahrain Linux User Group for five years. During that period I was a regular speaker at the groups monthly meetups. I’ve taught courses in python programing and computer networking to both students and working professionals.
I've given talks at two python conferences before: