A Comparative Study of Pure Python and JAX-Based Approaches in Computing Harmonic Series
A Comparative Study of Pure Python and JAX-Based Approaches in Computing Harmonic Series Mehmet Keçeci Orcid : https://orcid.org/0000-0001-9937-9839 Received : 2025-07-29 Abstract This study presents a comprehensive evaluation of computational performance, memory efficiency, and algorithmic scalability comparing traditional pure Python and NumPy implementations (oresme) against modern JAX/XLA (oresmej) and Numba/LLVM (oresmen) architectures for computing harmonic series. Experimental benchmarks were conducted across three distinct workload scales under both standard GIL-enabled Python 3.15.2 and free-threading (3.15.2t) builds, measuring cold-start compilation latency, steady-state hot-run execution, and peak memory footprint. While exact rational arithmetic (Fraction) guarantees mathematical precision, its O(N²) memory growth creates severe bottlenecks at scale. Conversely, in high-scale single-array evaluations (N = 250,000), JAX JIT leverages XLA kernel fusion to achieve 2.27 GOPS (110.34 μs), yielding a 67.3x speedup over pure Python, while Numba achieves a 27.3x speedup (272.50 μs). Furthermore, this work resolves the 33.17 s recompilation bottleneck triggered by naive Python loops calling JAX during batch queries (B = 1,500) through a two-stage architectural optimization. First, static-shape masking with jax.vmap eliminates dynamic recompilation and reduces execution time to 13.58 ms. Second, replacing the O(B · N max) matrix mask with a cumulative sum (jnp.cumsum) prefix table and O(1) indexing lowers complexity to O(N max + B), reducing batch latency to 58.18 μs and achieving a 4,232.6x acceleration over pure Python. Finally, analytical asymptotic approximations based on the Euler–Mascheroni constant deliver over 20,000x speedups, demonstrating that memory-aware algorithmic design is essential for high-throughput, energy-efficient scientific computing.
- Link
- https://zenodo.org/records/24244213
- Found by
- Zenodo
- Authors
- Keçeci, Mehmet
- Categories
- benchmark, evaluation
- Published
- 2026-11-15
- Last seen by the radar
- 2026-11-15
- Downloads
- 287
- Views
- 535
- Radar score
- 55.41 / 100 (how it is scored)
- Why it scored so
- Matched: benchmark, evaluat; Recency discount: updated event ×0.5; Primary record: Zenodo
- Related links
- https://doi.org/10.5281/zenodo.24244213