Most of the time, readability is more important than the performance of scientific software. This page contains tips for improving the performance of PlasmaPy for situations where performance becomes a bottleneck.
Upgrade to the newest version of Python to take advantage of ongoing performance improvements from the Faster CPython project. New versions of Python also have improved error message, which can speed up the debugging process too.
A new version of Python is released in October of each year, and can be used with PlasmaPy a few months later.
Using Astropy units
Because PlasmaPy uses SI units internally, performance can be improved
slightly by providing
Quantity objects in SI units to functions in
plasmapy.formulary. Unit conversions done by the
decorator then do not need to be performed.
Many of the functions in
plasmapy.formulary accept particle-like
arguments. Arguments that are not already a
ParticleList are converted into one (usually via
particle_input() decorator. When a formulary function is repeatedly
called, performance can be improved by creating the particle object
ahead of time.
Lite-functions accept and return NumPy arrays (assumed to be in SI
units) instead of
Quantity objects. Lite-functions make use of
just-in-time (JIT) compilation via Numba to achieve high performance.
Because lite-functions do not include any validation of inputs, they
should only be used for performance-critical applications.