Numpy Comes To Micro Python

[Zoltán] sends in his very interesting implementation of a NumPy-like library for micropython called ulab.

He had a project in MicroPython that needed a very fast FFT on a micro controller, and was looking at all of the options when it occurred to him that a more structured approach like the one we all know and love in CPython would be possible on a micro controller too. He thus ended up with a python library that could do the FFT 50 times faster than the the pure Python implementation while providing all the readability and ease of use benefits that NumPy and Python together provide.

As cool as this is, what’s even cooler is that [Zoltan] wrote excellent documentation on the use of the library. Not only can this documentation be used for his library, but it provides many excellent examples of how to use MicroPython itself.

We really recommend that fans of Python and NumPy give this one a look over!

10 thoughts on “Numpy Comes To Micro Python

  1. “MicroPython that needed a very fast FFT on a micro controller..”

    I love Python and the myriad and dazzling amalgam of frameworks and libs that are available. And I like that Python has enabled many scientists to do some amazing stuff – and as (choke) the ardy stuff has enabled the artistic non-STEM types to create some interesting stuff. But there are limits to the expectations of this language on microcontrollers. I use Python (mostly 3) for personal projects and for ‘playing’ with new ideas. I no longer use Python in a professional venue.

    If you truly need deterministic and/or performant (is that a word?) code, Python should not be used. And it never should be used for systems where protection of property and human safety are effective requirements. I have seen some really nasty things happen in industrial and manufacturing environments because of Python issues.

    Story time. Some problems resulted from attempting to convert from 2 to 3 (which can be considered different languages). A previous client had to update their ATE and other stuff when an important customer changed requirements, and there was the many changes in EMC, safety, and documentation requirements per new regulations and standards. The three programmers (sharp young minds with master degrees in CS) that were assigned to update the ATE and SPC stuff putzed around for some months when a review by the manufacturing and quality engineers could not find anything useful or working. Some engineering bosses looked at the project and the programmers were fired, and the tasked was assigned to a manufacturing engineer, a quality engineer, and a regulatory engineer. We stared at the code for several days then threw it away and did a re-design and re-wrote in C/C++. We had the ATE and production lines back up in 8 days, and the quality stuff in 17 days. A year later, these systems are still humming along, making the company money while the birds sing, the bunnies frolic, and the cicadas chirp happily away…

    1. Maybe it’s just my discipline, but I totally disagree with the idea that Python should not be used for performant code. That may have been the case in the old days, but today there are numerous libraries that do all the important processing in the backend and are nearly as fast as C. The most obvious example probably being Numpy, and another being Tensorflow.
      Some may ask why bother using these in the first place instead of C/C++. For me, the reason is much, much faster speed of iteration.
      I do computational geometry research for a medical device company and iterating in Python is so much faster to change things and visualize the results, versus a C program, it’s not even funny.
      I do agree with you though that I would not use it for industrial or safety-critical environments. This is all purely research.

  2. We need a different word. Microcontroler implies a small slow device. The STM32F4xxx parts commonly used with MicoPython are running at least 200 VaxMIPS.

    And I gotta ask, what chip are you using that doesn’t have a good FFT binary or C/assembly source available (

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.