Skip to main content

Performance Comparison of Python Translators for a Multi-threaded CPU-Bound Application

  • Conference paper
  • First Online:
Computer Science – CACIC 2021 (CACIC 2021)

Part of the book series: Communications in Computer and Information Science ((CCIS,volume 1584))

Included in the following conference series:

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 69.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 89.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    Programs that perform a large number of calculations using the CPU exhaustively.

  2. 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. 3.

    https://github.com/Pastorsin/python-hpc-study/.

  4. 4.

    The LLVM Compiler Infrastructure, https://llvm.org/.

  5. 5.

    Each previous version is labeled as Reference in all graphics.

  6. 6.

    A widely accepted convention in the literature for this problem.

  7. 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

  1. Decorators - Python Tips 0.1 documentation. https://book.pythontips.com/en/latest/decorators.html

  2. Cython: C-Extensions for Python. https://cython.org/

  3. Home - OpenMP. https://www.openmp.org/

  4. Home — Jython. https://www.jython.org/

  5. 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/

  6. Numba documentation - Numba 0.53.1-py3.7-linux-x86_64.egg documentation. https://numba.readthedocs.io/en/stable/index.html

  7. NumPy. https://numpy.org/

  8. PyPy. https://www.pypy.org/

  9. Sunsetting Python 2 — Python.org. https://www.python.org/doc/sunset-python-2/

  10. What Is the Python Global Interpreter Lock (GIL)? - Real Python. https://realpython.com/python-gil/

  11. 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

    Article  Google Scholar 

  12. 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

  13. 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

    Article  Google Scholar 

  14. Intel Corp.: How to manipulate data structure to optimize memory use on 32-bit intel® architecture (2018). https://tinyurl.com/26h62f76

  15. Marowka, A.: Python accelerators for high-performance computing. J. Supercomput. 74(4), 1449–1460 (2017). https://doi.org/10.1007/s11227-017-2213-5

    Article  Google Scholar 

  16. 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

  17. 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)

    Google Scholar 

  18. 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

    Chapter  Google Scholar 

  19. TIOBE Software BV: TIOBE Index for November 2021 (2021). https://www.tiobe.com/tiobe-index/

  20. 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)

    Google Scholar 

  21. Wilbers, I., Langtangen, H.P., Odegard, A.: Using cython to speed up numerical python programs. In: Proceedings of MekIT, pp. 495–512 (2009)

    Google Scholar 

  22. 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)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Enzo Rucci .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2022 The Author(s), under exclusive license to Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

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)

Publish with us

Policies and ethics