Exploring concurrent programming.
sample_thread.py
allows testing multithreading and multiprocessing for different tasks, including I/O-bound and CPU-bound.
The following tests demonstrates that for CPU-bound tasks in Python, multithreading doesn't help, while multiprocessing helps.
- CPU-Bound, Sequential: ~15s (benchmark)
- CPU-Bound, Multithreading: ~15s (no gain)
- CPU-Bound, Multiprocessing: ~5s (huge gain)
sample_async.py
leverages Python's asyncio.