Accelerating Python with Cython, Numba and JAX#
Scott Brandenberg, UCLA and Krishna Kumar, UT Austin
A Hands-On Tutorial Wednesday, April 19, 2023, 2:00pm - 3:30pm US Central Time
The webinar will feature a hands-on component using DesignSafe Jupyter, so please be sure to register for a DesignSafe user account if you don’t already have one. If your existing account is inactive, reactivate it by resetting your password.
Python is a popular programming language in natural hazards engineering research because it is free and open-source, and has a plethora of powerful packages for handling our community’s computing needs. However, Python is an interpreted language and is inherently slower and less efficient than compiled languages like Fortran, C, and C++. As a result, many scripts written in Python, particularly those involving loops, can run significantly faster with a few minor modifications. This webinar will demonstrate how vectorized calculations using Numpy arrays are significantly faster than the same operations coded in Python. We will demonstrate how to use Cython to compile Python code to C, which can improve performance by orders of magnitude. We will also demonstrate how to use just in time (JIT) compilation and JAX (Numpy on steroids) to accelerate Python, particularly using GPU’s.