Gotcha 1: Parallelization#
Execution Behavior of Compiled Extensions:
Python scripts act as an orchestration facade.
Underlying libraries (e.g., NumPy) can save state, explicitly release the GIL, and delegate tasks to compiled C/Fortran code.
The compiled code utilizes true multi-core parallelism.
import numpy as np
size = 4000
arr1 = np.random.rand(size, size)
arr2 = np.random.rand(size, size)
for _ in range(100):
np.dot(arr1, arr2)