Skip to main content

Parakeet

Parakeet is a runtime accelerator for an array-oriented subset of Python. If you’re doing a lot of number crunching in Python, Parakeet may be able to significantly speed up your code.

To accelerate a function, wrap it with Parakeet’s @jit decorator:

import numpy as np
from parakeet import jit

x = np.array([1,2,3])
y = np.tanh(x * alpha) + beta

@jit
def fast(x, alpha = 0.5, beta = 0.3):
  return np.tanh(x * alpha) + beta

@jit
def loopy(x, alpha = 0.5, beta = 0.3):
  y = np.empty_like(x, dtype = float)
  for i in xrange(len(x)):
    y[i] = np.tanh(x[i] * alpha) + beta
  return y

@jit
def comprehension(x, alpha = 0.5, beta = 0.3):
  return np.array([np.tanh(xi*alpha) + beta for xi in x])

assert np.allclose(fast(x), y)
assert np.allclose(loopy(x), y)
assert np.allclose(comprehension(x), y)

Install

You should be able to install Parakeet from its PyPI package by running:

pip install parakeet

Dependencies

Parakeet is written for Python 2.7 (sorry internet) and depends on:

How does it work?

Your untyped function gets used as a template from which multiple type specializations are generated (for each distinct set of input types). These typed functions are then churned through many optimizations before finally getting translated into native code.

More information

Supported language features

Parakeet cannot accelerate arbitrary Python code, it only supports a limited subset of the language:

  • Scalar operations (i.e. “x + 3 * y”)

  • Control flow (if-statements, loops, etc…)

  • Nested functions and lambdas

  • Tuples

  • Slices

  • NumPy array expressions (i.e. “x[1:, :] + 2 * y[:-1, ::2]”)

  • NumPy array constructors (i.e. np.ones, np.empty, etc..)

  • NumPy ufuncs (i.e. np.sin, np.exp, etc..)

  • List literals (interpreted as array construction)

  • List comprehensions (interpreted as array comprehensions)

  • Parakeet’s “adverbs” (higher order array operations like parakeet.map, parakeet.reduce)

Backends

Parakeet currently supports compilation to sequential C, multi-core C with OpenMP (default), or LLVM (deprecated). To switch between these options change parakeet.config.backend to one of: * “c”: lowers all parallel operators to loops, compile sequential code with gcc * “openmp”: also compiles with gcc, but parallel operators run across multiple cores (default) * “cuda”: launch parallel operations on the GPU (experimental) * “llvm”: older backend, has fallen behind and some programs may not work

Release files for parakeet 0.22

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for parakeet 0.22
File Size Uploaded
parakeet-0.22.tar.gz 243.1 kB Details

Release files / parakeet-0.22.tar.gz

Download URL parakeet-0.22.tar.gz
Size 243.1 kB
Tags Source
SHA-256 checksum
How to use checksums
988363f808d98d390ca1628f3dc60afa7a63631b6c559b7fb0de024cdae65775
BLAKE2b-256 checksum
How to use checksums
1ba233317c707d47a8a31d37af1cba55c9f01f38ff564e5ee9e56779b646b5d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.24

1 release file

0.23.2

1 release file

0.23.1

1 release file

0.23

1 release file

This release

0.22 This release

1 release file

0.21

1 release file

0.20

1 release file

0.19

1 release file

0.18

1 release file

0.17.1

1 release file

0.17

1 release file

0.16.2

1 release file

0.16.1

1 release file

0.16

1 release file

0.14.2

1 release file

0.14.1

1 release file

0.14

1 release file

0.13

1 release file

0.12.1

1 release file

0.12

1 release file

0.11

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page