Research Article
Open access
Published on 4 February 2024
Download pdf
Zhang,Y. (2024). Comparative study of the execution efficiency of Python and C++——Based on topological sorting. Applied and Computational Engineering,34,13-17.
Export citation

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

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

* Author to whom correspondence should be addressed.

https://doi.org/10.54254/2755-2721/34/20230288

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

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

Cite this article

Zhang,Y. (2024). Comparative study of the execution efficiency of Python and C++——Based on topological sorting. Applied and Computational Engineering,34,13-17.

Data availability

The datasets used and/or analyzed during the current study will be available from the authors upon reasonable request.

Disclaimer/Publisher's Note

The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of EWA Publishing and/or the editor(s). EWA Publishing and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

About volume

Volume title: Proceedings of the 2023 International Conference on Machine Learning and Automation

Conference website: https://2023.confmla.org/
ISBN:978-1-83558-293-0(Print) / 978-1-83558-294-7(Online)
Conference date: 18 October 2023
Editor:Mustafa İSTANBULLU
Series: Applied and Computational Engineering
Volume number: Vol.34
ISSN:2755-2721(Print) / 2755-273X(Online)

© 2024 by the author(s). Licensee EWA Publishing, Oxford, UK. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license. Authors who publish this series agree to the following terms:
1. Authors retain copyright and grant the series right of first publication with the work simultaneously licensed under a Creative Commons Attribution License that allows others to share the work with an acknowledgment of the work's authorship and initial publication in this series.
2. Authors are able to enter into separate, additional contractual arrangements for the non-exclusive distribution of the series's published version of the work (e.g., post it to an institutional repository or publish it in a book), with an acknowledgment of its initial publication in this series.
3. Authors are permitted and encouraged to post their work online (e.g., in institutional repositories or on their website) prior to and during the submission process, as it can lead to productive exchanges, as well as earlier and greater citation of published work (See Open access policy for details).