Book Image

Mastering Python High Performance

Book Image

Mastering Python High Performance

Overview of this book

Table of Contents (15 chapters)

Parakeet


This one is the most specific tool yet to deal with numbers in Python. It is very specific because it only supports a very narrow subset of the resulting combination of Python and NumPy. So, if you're dealing with anything outside that universe, this might not be an option for you, but if you can fit your solution into it, then keep on reading.

To be more specific about the limited universe that Parakeet supports (normally useful only to express numerical computations), here is a short list:

  • Types supported by Python are numbers, tuples, slices, and NumPy's arrays

  • Parakeet follows the upcasting rule, that is, whenever two values of different types try to reach the same variable, they'll be upcast into a unifying one. For instance, the Python expression 1.0 if b else false would translate to 1.0 if b else 0.0, but when automatic casting isn't possible, such as 1.0 if b else (1,2), then an uncatchable exception (see next point) will be raised during compilation time.

  • Catching or even...