Research Article

Comparative study of the execution efficiency of Python and C++——Based on topological sorting

Yuwei Zhang*
Gaston Day School, Gastonia, North Carolina, United States, 28056

* Corresponding author: [email protected]

Abstract

C++, a compiled language, and Python, an interpreted language, are among those essential coding languages that function in diverse areas of the current computer industry. However, different languages have disparate benefits and fit in various circumstances. When large amounts of data are involved or fast execution speed is required, one should consider which language performs better. This research mainly aims to find out whether C++ or Python is more efficient through Topological Sorting, which is utilized to linearize the vertices of a Directed Acyclic Graph (DAG). In the approach of coding the Topological Sorting algorithm in C++ and Python and comparing their execution times on each matrix representing a DAG randomly generated by a Python program, it is concluded that C++ generally has a higher efficiency than Python.

Keywords: C++; Python; execution efficiency; topological sorting; comparing
Published: February 4, 2024
DOI: 10.54254/2755-2721/34/20230288
Volume: ACE Vol.34
pp. 13-17
Download PDF

References

  1. Mohana Lakshmi, J., Suresh, H. N., & Pai, V. K. (2018). Nonlinear Speed Estimator and Fuzzy Control for Sensorless IM Drive. In Proceedings of First International Conference on Smart System, Innovations and Computing: SSIC 2017, Jaipur, India (pp. 307-318). Springer Singapore.
  2. Kahn, A. B. (1962). Topological Sorting of Large Networks. Communications of the ACM, 5(11), 558-562.
  3. M. Soyah, "Exchanged electricity paths calculation in integrated and sustainable power systems using topological sort," 2021 12th International Renewable Energy Congress (IREC), Hammamet, Tunisia, 2021, pp. 1-5, doi: 10.1109/IREC52758.2021.9624764.
  4. Sebesta, R. W. (2012). Concepts of Programming Languages - 10th Edition. Pearson Addison Wesley.
  5. Nosrati, M. (2011). Python: An Appropriate Language for Real World Programming. World Applied Programming, 1(2), 110-117.
  6. Zehra, F., Javed, M., Khan, D., & Pasha, M. (2020). Comparative Analysis of C++ and Python in Terms of Memory and Time. Preprints.org. https://doi.org/10.20944/preprints202012.0516.v1.
  7. S. Abdulsalam, D. Lakomski, Q. Gu, T. Jin and Z. Zong, "Program energy efficiency: The impact of language, compiler and implementation choices," International Green Computing Conference, Dallas, TX, USA, 2014, pp. 1-6, doi: 10.1109/IGCC.2014.7039169.
  8. Naz, A., Nawaz, H., Maitlo, A., & Hassan, S. M. (2021). Implementation of Selection Sort Algorithm in Various Programming Languages. International Journal of Advanced Trends in Computer Science and Engineering, 10(3). https://doi.org/10.30534/ijatcse/2021/1071032021.
  9. Tait, J., Ripke, T., Roger, L., & Matsuo, T. (2018, December). Comparing Python and C++ Efficiency Through Sorting. In 2018 International Conference on Computational Science and Computational Intelligence (CSCI) (pp. 864-871). IEEE.
  10. Agha, F. A., & Nawaz, H. (2021). Comparison of Bubble and Insertion Sort in Rust and Python Language. International Journal of Advanced Trends in Computer Science and Engineering, 10(2). https://doi.org/10.30534/ijatcse/2021/761022021.