Parallel computing, cython, numba, multi-processing and multi-threading in Python.
- Python was created for humans and to help them experiment idea faster. Many details such as variable types and memory allocation and deallocation are then left to the runtime to decide.
- The downside is that Python is slower and harder to optimise - than languages like C or Fortran.
- So, why are we still sticking to python? No! Most program have few part that are time-critical. Even, for this parts, itis possible to achieve the same speed as C or Fortran.
- The growth of CPU clock speed (i.e., the speed at which a single chain of logic can be run) has slowed dramatically.
- As a response, hardware makers have increased the number of cores (physical CPUs) embedded in each machine as a differnt avenue to fast execution: parallelisation.
- Concurrency is the capability of having more than one computation in progress at the same time.
- Concurrency is a different type of programming. So not only: procedural, functional and OOP.
- Concurrency is what allows: concurrent, parallel and asynchronous execution.
-
- Native:
- Python multiprocessing for process-based concurrency. A process refers to a computer program. Multiprocesses are appropriate for CPU-bound tasks, and not I/O-bound tasks.
- Python threading for thread-based concurrency. A thread refers to a thread of execution by a computer program. Because of the GIL, threads are appropriate for I/O-bound tasks, and not CPU-bound tasks.
- Python asyncio for coroutine-based concurrency. A coroutine is a unit of concurrency that is more lightweight than a thread.
- Third parties:
- ray: a framework for scaling Python applications.
- tornado: Python web framework and asynchronous networking library.
- celery: Distributed task queue.
- sanic: Async Python web server and framework.
- aiohttp: Asynchronous HTTP client/server framework for asyncio
- dask: Parallel computing with task scheduling.
- uvloop: Ultra fast asyncio event loop.
- Caching
- Code profiling
- Concurrency
- Cython - Bridging the gap between Python and Fortran
- Cython & Numba, C-like performance
- Cython vs. Numba vs. Parakeet on Bubblesort
- How to cythonise your code
- How to optimise scikit-learn execution time
- Implicit Multithreading in NumPy
- Memoisation and decorators
- Multiprocessing
- numba
- NumPy vs. Numba vs. Cython
- Parallel programming with Python (threading, multiprocessing
- Profiling Scikit-Learn Parallel Job
- Python's and NumPy's in-place operator functions
- Scoop
- Speeding up NumPy array expressions with Numexpr
- Vectorisation
- Vectorizing a classic for-loop in NumPy
- Atomic operations
- The counter-intuitive rise of Python in scientific computing
- Need for speed
- Parallelisation
- SuperFastPython
- Concurrency vs. Parallelism