This project is no longer being maintained.
Parakeet was a runtime accelerator for an array-oriented subset of Python. In retrospect, I don't think that whole-function type specialization at the AST level is a scalable approach to speeding up a sufficiently large subset of Python. General-purpose Python code should probably be accelerated using a bytecode JIT, whereas high-performance numerical code should use a DSL with explicit parallel operators.
To accelerate a function, wrap it with Parakeet's @jit decorator:
import numpy as np from parakeet import jit alpha = 0.5 beta = 0.3 x = np.array([1,2,3]) y = np.tanh(x * alpha) + beta def fast(x, alpha = 0.5, beta = 0.3): return np.tanh(x * alpha) + beta 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 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)
You should be able to install Parakeet from its PyPI package by running:
pip install parakeet
Parakeet is written for Python 2.7 (sorry internet) and depends on:
The default backend (which uses OpenMP) requires
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.
Parakeet cannot accelerate arbitrary Python code, it only supports a limited subset of the language:
x + 3 * y)
x[1:, :] + 2 * y[:-1, ::2])
np.sin(look at the mappings module for a full list)
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: