AbstractsComputer Science

Benchmarking Python Interpreters; Jämförelse av Pythoninterpreterarna CPython, Cython, Jython och PyPy

by Alexander Roghult




Institution: KTH Royal Institute of Technology
Department:
Year: 2016
Keywords: Python Cython CPython Jython PyPy; Natural Sciences; Computer and Information Science; Computer Science; Naturvetenskap; Data- och informationsvetenskap; Datavetenskap (datalogi); Master of Science in Engineering - Computer Science and Technology; Civilingenjörsexamen - Datateknik
Posted: 02/05/2017
Record ID: 2116610
Full text PDF: http://urn.kb.se/resolve?urn=urn:nbn:se:kth:diva-183547


Abstract

For the Python programming language there are several different interpreters and implementations. In this thesis project the performance regarding execution time is evaluated for four of these; CPython, Cython, Jython and PyPy. The performance was measured in a test suite, created during the project, comprised of tests for Python dictionaries, lists, tuples, generators and objects. Each test was run with both integers and objects as test data with varying problem size. Each test was implemented using Python code. For Cython and Jython separate versions of the test were also implemented which contained syntax and data types specific for that interpreter. The results showed that Jython and PyPy were fastest for a majority of the tests when running code with only Python syntax and data types. Cython uses the Python C/API and is therefore dependent on CPython. The performance of Cython was therefore often similar to CPython. Cython did perform better on some of the tests when using Cython syntax and data types, as it could therefore decrease its reliance to CPython. Each interpreter was able to perform fastest on at least one test, showing that there is not an interpreter that is best for all problems. ; Det existerar flera olika implementationer och interpreterare för programmeringsspråket Python. I detta examensarbete evalueras prestandan avseende exekveringstid för fyra av dessa; CPython, Cython, Jython och PyPy. Prestandan mättes i en testsvit som skapades i detta projekt. Testsviten bestod av tester för Pythons dictionary, list, tuple, generator och objekt. Varje test kördes med bå de heltal och objekt som testdata med varierande problemstorlek. Varje test var implementerat i programmeringsspråket Python. För Cython och Jython implementerades ytterliggare en version av testerna som innehöll syntax och datatyper specifika för dessa interpreterare. Resultaten visade att Jython och PyPy var snabbast för en majoritet av testerna som endast använde sig av Pythons syntax och datatyper. Cython använder sig av Pythons C/API och är därför beroende av CPython. Prestandan av Cython var därför lik CPythons. Cython presterade bättre på vissa av testerna som utnyttjade Cythons syntax och datatyper, då den därmed kunde minska sitt beroende av CPython. Varje interpreterare lyckades prestera snabbast på minst ett test. Detta visar att det inte finns en interpreterare som är mest lämpad för alla problem.