Python and MicroPython - Compare and Access

Updated 07 August 2020

Both Python and MicroPython are powerhouse programming languages. Each of them is capable of supporting your programming needs to almost the limits of your imagination. Both languages are transportable, open-source, growing in popularity, comparatively easy to learn and free! So how exactly do they differ from each other? The biggest factor is that Python, because of intensive processing demands requires full-sized desktop computers, laptops or cloud-servers to run. In comparison, the hardware requirements of MicroPython are orders of magnitude lower. This means MicroPython can operate effectively on microcontrollers and microprocessors.

Quick links for the contents of this guide is seen below.

Programming is the implementation of logic to facilitate specified computing operations and functionality. Simply put it is a way to instruct computers to perform various tasks using a programming language. microcontroller is a compact integrated circuit designed to govern a specific operation in an embedded system. A microprocessor is an integrated circuit that contains all the functions of a central processing unit of a computer which includes an operating system. Both these devices can easily fit on the palm of your hand and encourage in makers rainbows of creativity.

There are several related tutorials on our website and if you've got any questions, queries or things to add please let us know your thoughts!


Languages Overview

BigTubePerson GangThe syntax of Python presents itself with high human readability. Compared with other programming languages, such as C++ or Assembler, it is easy to learn and faster to write. Furthermore, the total length of code to perform a task tends to be shorter when compared to other programming languages. Programmers can often become preoccupied with minimising the execution time of code however it is worth realising that development time usually takes the longest. Python is growing particularly in the data sciences with large developments occurring in machine learning, physical modelling, geographic information systems (GIS) and computer vision. 

Python comes with an extensive standard library and gives a huge number of object types, functions and modules. All of these are available for use without importing any external modules.  There is more than hundred-thousand external Python packages available for download and use. A great repository for this is the Python Package Index. No matter what direction the project takes, almost always, you can hit the ground running and program. 

MicroPython is a port of Python designed to run on microcontrollers and microprocessors. These are devices that are much smaller, less powerful and significantly cheaper than a desktop computer. A regular version of Python would not be able to run on a microcontroller as it requires too much processing power and RAM energy. To run on these devices Python has to undergo several streamlining changes. This was done by the Australian programmer and physicist Damien George who originally created MicroPython. It is effectively a stand-alone, stripped-down version of Python. As a programming language, MicroPython is very similar to Python and any previous experience translates across very efficiently.

MicroPython contains only a subset of all the standard library modules included with Python. A module is a Python object with arbitrarily named attributes that you can bind and reference. A library is a collection of a whole bunch of these modules. Furthermore, some of the included MicroPython libraries do not have the full set of functions and classes that come with Python. function is a block of code which only runs when it is called. Classes are essentially a template to determine variables and functions of objects. Objects are simply a collection of data. Python and MicroPython are both object-oriented programming languages. These changes turn MicroPython into an extremely compact programming language. It takes up less than a megabyte of storage space and under load utilizes around 16k of RAM. Learning the programming language of MicroPython will present an immense amount of freedom and power.


MicroPython Compatible BoardsRaspberry Pi 4 Model B

Projects you can do with MicroPython running on small, low-cost boards are unlimited. Want to make a motor spin, light a bouquet of LED lights, create a weather station, receive feedback from a weather-balloon, control a quadcopter, create a micro-satellite, control robots or build a deep-sea submarine? Then MicroPython is the perfect backbone to your venture and the programing language to choose.

Some boards that MicroPython would be excellent for are seen below. This is by no means an exhaustive list.

- Raspberry Pi Boards
- LattePanda Boards
- Arduino Boards

PyBoards
Intel Edison Boards
Particle Boards
Onion Boards
Teensy Boards

Micro:Bit by BBC
Development Boards 

- SparkFun Boards such as ESP8266, ESP32
- PYCOM Boards such as WiPyGPyFiPyLoPy4

- Adafruit Boards such as Circuit Playground, Feather Boards


Download Links and Browser-Based Online Emulator

MicroTubePerson GangBoth Python and MicroPython programming languages are free to download and use. They are also open-source giving individuals the freedom to modify, contribute and propose improvements. Download locations can be seen below.

- To Download Python

- To Download MicroPython

There are also online browser-based emulators for both Python and MicroPython. The MicroPython emulator will show command results on a virtual microprocessor. This means you don't even need to download to test out and run commands using each of these programming languages. The locations to access these emulators are seen below.

- Python Browser-Based Compiler Emulator

- MicroPython Browser-Based Compiler Emulator


Deep Dive on Differences Between Python and MicroPython

Here are the nitty-gritty differences that happens when you turn a powerhouse programming language into one that takes up a fraction of processing power. This will be a high-level comparison of Python and MicroPython programming languages.

MicroPython is intended for constrained environments which have orders of magnitude less performance and memory than a desktop system. This means by design there will be various changes between Python and MicroPython programming languages which are explored below.

Real Sneaky Tube Person Gang- MicroPython does not support the entire Python standard library. If a module is missing it will be due to the poor applicability of that module for use in a small board. If high memory consumption or a lack of a certain required hardware feature, such as multiprocessing, then associated modules were excluded.

- MicroPython is less forgiving in regards to syntax. An example of this is it requires spaces between literal numbers and keywords.

- MicroPython uses garbage collection as the primary means of memory management.

- Metaclasses and complicated Multiple Inheritance won't work in MicroPython because of a lack of complete object data models. Metaclass in Python is a class of a class that defines how a lower-level class will behave. Multiple Inheritance is a feature that makes all the base class features be inherited into a derived class.

- MicroPython design does not allow descriptor implements. Descriptors are Python objects which give you the ability to create objects that have special behaviour when they’re accessed as attributes of other objects.

- MicroPython implements only a subset of functionality and a subset of parameters of particular functions and classes. If these are required you will need to manually import them.

- MicroPython supports a minimal subset of introspection and reflection features such as object names and docstrings. Introspection is the ability to determine the type of an object at runtime. Reflection refers to the ability for code to be able to examine attributes about objects that might be passed as parameters to a function. A docstring is a string literal that occurs as the first statement in a module, function, class, or method definition. A string literal is where you specify the contents of a string in a program. Strings are arrays of bytes representing Unicode characters. Unicode is an international encoding standard for use with different languages and scripts, by which each letter, digit, or symbol is assigned a unique numeric value that applies across different platforms and programs. 

- MicroPython does the | print() | function differently. It does not check for recursive data structures in the same way. Checks are done so printing recursive data structure will not lead to stack overflow. A stack overflow is an undesirable condition in which a particular computer program tries to use more memory space than is available causing crashes.

- MicroPython optimizes local variable handling. It does this by not recording or providing introspection information. In programming, introspection is the ability to find out information about an object at runtime.

 

Compared to a desktop computer a microprocessor or microcontroller can be viewed as a constrained system. Some features of Python do not cater well for constrained systems and/or are not easy to implement efficiently or at all. Therefore there are differences between Python and MicroPython programming languages that have to do with implementation which can be seen below.

Green Tube Bro- MicroPython has only some Unicode Support. 

- In MicroPython Object finalisation is not supported for user-created Classes.

- Subclassing of Built-in Types is partly implemented on MicroPython. Principal Built-in Types are numerics, sequences, mappings, classes, instances and exceptions. Others Built-in Types are used during program execution and are of little practical use to most programmers.

- Buffered I/O streams are not supported in MicroPython. Using this technique you can minimise the number of system calls and can block-align I/O operations, which may improve the performance of your application. I/O operations (also referred to as input/output operations) is the communication between an information processing system, such as a computer, and the outside world.

- The | async def | Function is implemented with simplifications into MicroPython. This keyword introduces either a native coroutine or an asynchronous generator. A coroutine is a specialized version of a Python generator function. Generator functions allow you to declare a function that behaves like an iterator.  An iterator is an object that can be iterated upon which means that you can traverse through all the values. An example of this would be a For loop. Asynchronous programming or operation is a type of parallel programming in which a unit of work can run separately from the primary application code.

- There's no support for Future-esque Objects in MicroPython. A Future Object is a special low-level awaitable object that represents an eventual result of an asynchronous operation. An object is an awaitable object if it can be used in an asynchronous operation. There are three main types of awaitable objects which are coroutines, Tasks, and Futures.

- In MicroPython the | __dict__ | keyword is read-only and either disabled or optional. This keyword is referred to as the dictionary and contains all the attributes which describe the object in question. It can also be used to alter or read the attributes.

Have a question? Ask the Author of this guide today!

Please enter minimum 20 characters

Your comment will be posted (automatically) on our Support Forum which is publicly accessible. Don't enter private information, such as your phone number.

Expect a quick reply during business hours, many of us check-in over the weekend as well.

Comments


Loading...
Feedback

Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.