Abstract
Currently, Python is one of the most widely used languages in various application areas. However, it has limitations when it comes to optimizing and parallelizing applications due to the nature of its official CPython interpreter, especially for CPU-bound applications. To solve this problem, several alternative translators have emerged, each with a different approach and its own cost-performance ratio. Due to the absence of comparative studies, we have carried out a performance comparison of these translators using N-Body as a case study (a well-known problem with high computational demand). The results obtained show that CPython and PyPy presented poor performance due to their limitations when it comes to parallelizing algorithms; while Numba and Cython achieved significantly higher performance, proving to be viable options to speed up numerical algorithms.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
Programs that perform a large number of calculations using the CPU exhaustively.
- 2.
Process performed by a special class of compiler, which consists in producing source code in one language based on source code in a different language.
- 3.
- 4.
The LLVM Compiler Infrastructure, https://llvm.org/.
- 5.
Each previous version is labeled as Reference in all graphics.
- 6.
A widely accepted convention in the literature for this problem.
- 7.
The implementation executed with PyPy was the naive version since the other versions use NumPy arrays and PyPy is unable to optimize them.
References
Decorators - Python Tips 0.1 documentation. https://book.pythontips.com/en/latest/decorators.html
Cython: C-Extensions for Python. https://cython.org/
Home - OpenMP. https://www.openmp.org/
Home — Jython. https://www.jython.org/
Microsoft’s new research lab studies developer productivity and well-being — VentureBeat. https://venturebeat.com/2021/05/25/microsofts-new-research-lab-studies-developer-productivity-and-well-being/
Numba documentation - Numba 0.53.1-py3.7-linux-x86_64.egg documentation. https://numba.readthedocs.io/en/stable/index.html
NumPy. https://numpy.org/
PyPy. https://www.pypy.org/
Sunsetting Python 2 — Python.org. https://www.python.org/doc/sunset-python-2/
What Is the Python Global Interpreter Lock (GIL)? - Real Python. https://realpython.com/python-gil/
Cai, X., Langtangen, H.P., Moe, H.: On the performance of the python programming language for serial and parallel scientific computations. Sci. Program. 13(1), 31–56 (2005). https://doi.org/10.1155/2005/619804
Costanzo, M., Rucci, E., Naiouf, M., Giusti, A.D.: Performance vs programming effort between rust and C on multicore architectures: case study in N-body. In: 2021 XLVII Latin American Computer Conference (CLEI) (2021). https://doi.org/10.1109/CLEI53233.2021.9640225
Gmys, J., Carneiro, T., Melab, N., Talbi, E.G., Tuyttens, D.: A comparative study of high-productivity high-performance programming languages for parallel metaheuristics. Swarm Evol. Comput. 57, 100720 (2020). https://doi.org/10.1016/j.swevo.2020.100720
Intel Corp.: How to manipulate data structure to optimize memory use on 32-bit intel® architecture (2018). https://tinyurl.com/26h62f76
Marowka, A.: Python accelerators for high-performance computing. J. Supercomput. 74(4), 1449–1460 (2017). https://doi.org/10.1007/s11227-017-2213-5
Milla, A., Rucci, E.: Acelerando Código Científico en Python usando Numba. XXVII Congreso Argentino de Ciencias de la Computación (CACIC 2021), p. 12, October 2021. http://sedici.unlp.edu.ar/handle/10915/126012
Roghult, A.: Benchmarking Python interpreters: measuring performance of CPython, Cython, Jython and PyPy. Master’s thesis, School of Computer Science and Communication, Royal Institute of Technology, Sweden (2016)
Rucci, E., Moreno, E., Pousa, A., Chichizola, F.: Optimization of the N-body simulation on intel’s architectures based on AVX-512 instruction set. In: Pesado, P., Arroyo, M. (eds.) CACIC 2019. CCIS, vol. 1184, pp. 37–52. Springer, Cham (2020). https://doi.org/10.1007/978-3-030-48325-8_3
TIOBE Software BV: TIOBE Index for November 2021 (2021). https://www.tiobe.com/tiobe-index/
Varsha, M., Yashashree, S., Ramdas, D.K., Alex, S.A.: A review of existing approaches to increase the computational speed of the Python language. Int. J. Res. Eng. Sci. Manag. (2019)
Wilbers, I., Langtangen, H.P., Odegard, A.: Using cython to speed up numerical python programs. In: Proceedings of MekIT, pp. 495–512 (2009)
Wilkens, F.: Evaluation of performance and productivity metrics of potential programming languages in the HPC environment. Bachelor’s thesis, Faculty of Mathematics, Informatics und Natural Sciences, University of Hamburg, Germany (2015)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2022 The Author(s), under exclusive license to Springer Nature Switzerland AG
About this paper
Cite this paper
Milla, A., Rucci, E. (2022). Performance Comparison of Python Translators for a Multi-threaded CPU-Bound Application. In: Pesado, P., Gil, G. (eds) Computer Science – CACIC 2021. CACIC 2021. Communications in Computer and Information Science, vol 1584. Springer, Cham. https://doi.org/10.1007/978-3-031-05903-2_2
Download citation
DOI: https://doi.org/10.1007/978-3-031-05903-2_2
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-031-05902-5
Online ISBN: 978-3-031-05903-2
eBook Packages: Computer ScienceComputer Science (R0)