JIT's Amortized Cost vs. FFI's Per-Call Tax

JIT compilation incurs an initial overhead to translate bytecode into optimized machine code, making it most effective for functions repeatedly evaluated over long periods, where this upfront cost is amortized. Conversely, FFI has a consistent 'tax' per call, including object conversion and GIL acquisition/release, which can become a bottleneck for extremely frequent, tiny native calls, but is negligible when the native function performs substantial work.

Sources

Open the full topic