# ulab: Crunch Numbers fast in CircuitPython

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/088/977/medium800thumb/sensors_5e62c7536ec82980387928.jpg?1583531951)

## What is ulab

ulab (pronounced "micro lab") lets you perform number crunching tasks in CircuitPython more quickly, often around 10x as fast. This can be very handy when dealing with sensor data, as we'll see below.

Make sure you have CircuitPython 5.1.0 or newer, and any Adafruit CircuitPython board with an M4 or higher processor, including most SAMD51 and nRF boards.

It's a "built-in module", meaning that it is installed when you install CircuitPython, it's not a file or a set of files in a project bundle or installable via circup. Check the "Built-in modules available" list for a particular board on circuitpython.org to find out if it's available, or just run `import ulab` at the repl to find out for yourself immediately. If the result is an **ImportError** , then ulab is not available on that board.

ulab is modeled after [`numpy`](https://numpy.org/), but is not entirely compatible; so after the examples there are guidelines to help you move between numpy and ulab.

ulab is not available in Blinka, Adafruit's Single Board Computer layer for CircuitPython - for those boards we recommend using plain numpy since it's available! If your code needs to run on both CircuitPython and Blinka, you'll probably either need to use conditional code or forego the use of ulab altogether.

Warning: 

## The ulab API

ulab makes things faster by operating on entire arrays of values in one operation.&nbsp; For example, when you have two _numbers_ `a` and `b`, `a+b` adds them together, returning a new _number_.&nbsp; When you have two ulab _arrays_ `a` and `b`, `a+b` adds the corresponding numbers in `a` to the corresponding numbers in `b`, returning a new _array_.&nbsp; Want to double every number in an array?&nbsp; That's `a*2`.&nbsp; Compute its sine?&nbsp; `ulab.numpy.sin(a)`.&nbsp; It also has special versions of functions like `sum` that act on a whole array and return a single number.&nbsp; [Documentation for all functions in ulab](https://circuitpython.readthedocs.io/en/latest/shared-bindings/ulab/) are on readthedocs.

These examples only cover a portion of the functions available in ulab.&nbsp; The items below are beyond the scope of this gude:

- Matrix functions in `ulab.numpy.linalg`, such as determinant, inverse, and eigenvectors of a matrix
- Creating vectors with&nbsp;`ulab.numpy.linspace`, which is sort of like `range()` but for arrays
- Statistical functions such as standard deviation, `ulab.numpy.std` and others
- Functions for working with polynomials in `ulab.numpy.polyfit` and&nbsp;`ulab.numpy.polyval`
- Slicing arrays with `arr[lo:hi:step]`

## Parts
Featured
### Adafruit CLUE - nRF52840 Express with Bluetooth® LE

[Adafruit CLUE - nRF52840 Express with Bluetooth® LE](https://www.adafruit.com/product/4500)
Do you feel like you just don't have a CLUE? Well, we can help with that - get a CLUE here at Adafruit by picking up this sensor-packed development board. We wanted to build some projects that have a small screen and a lot of sensors. To make it compatible with existing projects, we made...

In Stock
[Buy Now](https://www.adafruit.com/product/4500)
[Related Guides to the Product](https://learn.adafruit.com/products/4500/guides)
![Animated GIF showing CLUE board  displaying data from the many on-board sensors.](https://cdn-shop.adafruit.com/product-videos/640x480/4500-04.jpg)

Featured
### Adafruit APDS9960 Proximity, Light, RGB, and Gesture Sensor

[Adafruit APDS9960 Proximity, Light, RGB, and Gesture Sensor](https://www.adafruit.com/product/3595)
This breakout is chock full o' sensors! Add basic gesture sensing, RGB color sensing, proximity sensing, or ambient light sensing to your project with the&nbsp; **Adafruit APDS9960 Proximity, Light, RGB, and Gesture Sensor**. When connected to your microcontroller (running our...

In Stock
[Buy Now](https://www.adafruit.com/product/3595)
[Related Guides to the Product](https://learn.adafruit.com/products/3595/guides)
![Angled shot of a Adafruit APDS9960 Proximity, Light, RGB, and Gesture Sensor.](https://cdn-shop.adafruit.com/640x480/3595-06.jpg)

Featured
### Adafruit BMP280 I2C or SPI Barometric Pressure & Altitude Sensor

[Adafruit BMP280 I2C or SPI Barometric Pressure & Altitude Sensor](https://www.adafruit.com/product/2651)
Bosch has stepped up their game with their new BMP280 sensor, an environmental sensor with temperature, barometric pressure that is the next generation upgrade to the BMP085/BMP180/BMP183. This sensor is great for all sorts of weather sensing and can even be used in both I2C and...

In Stock
[Buy Now](https://www.adafruit.com/product/2651)
[Related Guides to the Product](https://learn.adafruit.com/products/2651/guides)
![Adafruit BMP280 I2C or SPI Barometric Pressure & Altitude Sensor - STEMMA QT](https://cdn-shop.adafruit.com/640x480/2651-08.jpg)

Featured
### Flexible Silicone Neon-like Skinny NeoPixel LED Strip

[Flexible Silicone Neon-like Skinny NeoPixel LED Strip](https://www.adafruit.com/product/4310)
You love NeoPixels, and you love silicone diffusion? Peep this&nbsp; **Flexible Silicone Neon-like Skinny NeoPixel LED Strip**! OK it's a bit of a mouthful, but check out the beautiful footage! It&nbsp;_looks_&nbsp;a lot like a slim strip of neon, but without the need...

In Stock
[Buy Now](https://www.adafruit.com/product/4310)
[Related Guides to the Product](https://learn.adafruit.com/products/4310/guides)
![Demo Video of hands squeezing and unraveling the illuminated Flexible Silicone Neon-like Skinny NeoPixel LED Strip.](https://cdn-shop.adafruit.com/product-videos/640x480/4310-00.jpg)

Featured
### USB cable - USB A to Micro-B

[USB cable - USB A to Micro-B](https://www.adafruit.com/product/592)
This here is your standard A to micro-B USB cable, for USB 1.1 or 2.0. Perfect for connecting a PC to your Metro, Feather, Raspberry Pi or other dev-board or microcontroller

Approximately 3 feet / 1 meter long

In Stock
[Buy Now](https://www.adafruit.com/product/592)
[Related Guides to the Product](https://learn.adafruit.com/products/592/guides)
![USB cable - USB A to Micro-B - 3 foot long](https://cdn-shop.adafruit.com/640x480/592-01.jpg)

- [Next Page](https://learn.adafruit.com/ulab-crunch-numbers-fast-with-circuitpython/a-simple-benchmark.md)

## Guide Products

### Adafruit CLUE - nRF52840 Express with Bluetooth® LE

[Adafruit CLUE - nRF52840 Express with Bluetooth® LE](https://www.adafruit.com/product/4500)
Do you feel like you just don't have a CLUE? Well, we can help with that - get a CLUE here at Adafruit by picking up this sensor-packed development board. We wanted to build some projects that have a small screen and a lot of sensors. To make it compatible with existing projects, we made...

In Stock
[Buy Now](https://www.adafruit.com/product/4500)
[Related Guides to the Product](https://learn.adafruit.com/products/4500/guides)
### Adafruit APDS9960 Proximity, Light, RGB, and Gesture Sensor

[Adafruit APDS9960 Proximity, Light, RGB, and Gesture Sensor](https://www.adafruit.com/product/3595)
This breakout is chock full o' sensors! Add basic gesture sensing, RGB color sensing, proximity sensing, or ambient light sensing to your project with the&nbsp; **Adafruit APDS9960 Proximity, Light, RGB, and Gesture Sensor**. When connected to your microcontroller (running our...

In Stock
[Buy Now](https://www.adafruit.com/product/3595)
[Related Guides to the Product](https://learn.adafruit.com/products/3595/guides)
### Adafruit BMP280 I2C or SPI Barometric Pressure & Altitude Sensor

[Adafruit BMP280 I2C or SPI Barometric Pressure & Altitude Sensor](https://www.adafruit.com/product/2651)
Bosch has stepped up their game with their new BMP280 sensor, an environmental sensor with temperature, barometric pressure that is the next generation upgrade to the BMP085/BMP180/BMP183. This sensor is great for all sorts of weather sensing and can even be used in both I2C and...

In Stock
[Buy Now](https://www.adafruit.com/product/2651)
[Related Guides to the Product](https://learn.adafruit.com/products/2651/guides)
### Flexible Silicone Neon-like Skinny NeoPixel LED Strip

[Flexible Silicone Neon-like Skinny NeoPixel LED Strip](https://www.adafruit.com/product/4310)
You love NeoPixels, and you love silicone diffusion? Peep this&nbsp; **Flexible Silicone Neon-like Skinny NeoPixel LED Strip**! OK it's a bit of a mouthful, but check out the beautiful footage! It&nbsp;_looks_&nbsp;a lot like a slim strip of neon, but without the need...

In Stock
[Buy Now](https://www.adafruit.com/product/4310)
[Related Guides to the Product](https://learn.adafruit.com/products/4310/guides)
### USB cable - USB A to Micro-B

[USB cable - USB A to Micro-B](https://www.adafruit.com/product/592)
This here is your standard A to micro-B USB cable, for USB 1.1 or 2.0. Perfect for connecting a PC to your Metro, Feather, Raspberry Pi or other dev-board or microcontroller

Approximately 3 feet / 1 meter long

In Stock
[Buy Now](https://www.adafruit.com/product/592)
[Related Guides to the Product](https://learn.adafruit.com/products/592/guides)
### Adafruit Feather nRF52840 Express

[Adafruit Feather nRF52840 Express](https://www.adafruit.com/product/4062)
The **Adafruit Feather nRF52840 Express** is the new Feather family member with Bluetooth® Low Energy and _native USB support_ featuring the nRF52840!&nbsp; It's our take on an 'all-in-one' Arduino-compatible + Bluetooth® Low Energy with built-in USB...

In Stock
[Buy Now](https://www.adafruit.com/product/4062)
[Related Guides to the Product](https://learn.adafruit.com/products/4062/guides)

## Related Guides

- [Adafruit BMP280 Barometric Pressure + Temperature Sensor Breakout](https://learn.adafruit.com/adafruit-bmp280-barometric-pressure-plus-temperature-sensor-breakout.md)
- [Introducing the Adafruit nRF52840 Feather](https://learn.adafruit.com/introducing-the-adafruit-nrf52840-feather.md)
- [Introducing Adafruit CLUE](https://learn.adafruit.com/adafruit-clue.md)
- [Easy Sparkle Pocket T-Shirt](https://learn.adafruit.com/easy-sparkle-pocket-t-shirt.md)
- [SpaceX Helmet](https://learn.adafruit.com/spacex-helmet.md)
- [Music Box with Dancing Adabot](https://learn.adafruit.com/music-box-with-circuit-python.md)
- [Making a PyPortal User Interface with DisplayIO](https://learn.adafruit.com/making-a-pyportal-user-interface-displayio.md)
- [How to Use micro:bit classroom to Manage Programming Lessons](https://learn.adafruit.com/how-to-use-micro-bit-classroom-to-manage-programming-lessons.md)
- [Trash Panda](https://learn.adafruit.com/trash-panda-circuit-python-crickit.md)
- [Make it Move with Crickit](https://learn.adafruit.com/make-it-move-with-crickit.md)
- [CircuitPython CLUE I Ching Caster](https://learn.adafruit.com/clue-i-ching-caster.md)
- [Adafruit Voice Bonnet](https://learn.adafruit.com/adafruit-voice-bonnet.md)
- [PyPortal Weekly Countdown Clock](https://learn.adafruit.com/pyportal-countdown-clock.md)
- [NeoTrellis M4 Animated Dice Roller](https://learn.adafruit.com/neotrellis-dice.md)
- [Halloween Monsters with CRICKIT and Circuit Playground Express](https://learn.adafruit.com/halloween-monsters-with-crickit.md)
- [Chinese Dragon Puppet with Motion-Reactive Flame Effect](https://learn.adafruit.com/chinese-dragon-puppet-with-motion-reactive-flame-effect.md)
- [Crickit Powered Mini Chair Swing Ride!](https://learn.adafruit.com/mini-chair-swing-ride.md)
- [Electronic History of the Day with PyPortal](https://learn.adafruit.com/electronic-history-of-the-day-with-pyportal.md)
