skip to main content
10.1145/2617548.2617552acmconferencesArticle/Chapter ViewAbstractPublication PagesecoopConference Proceedingsconference-collections
tutorial

Python Interpreter Performance Deconstructed

Published: 09 June 2014 Publication History

Abstract

The Python programming language is known for performing poorly on many tasks. While to some extent this is to be expected from a dynamic language, it is not clear how much each dynamic feature contributes to the costs of interpreting Python. In this study we attempt to quantify the costs of language features such as dynamic typing, reference counting for memory management, boxing of numbers, and late binding of function calls.
We use an experimental compilation framework for Python that can make use of type annotations provided by the user to specialize the program as well as elide unnecessary reference counting operations and function lookups. The compiled programs run within the Python interpreter and use its internal API to implement language semantics. By separately enabling and disabling compiler optimizations, we can thus measure how much each language feature contributes to total execution time in the interpreter.
We find that a boxed representation of numbers as heap objects is the single most costly language feature on numeric codes, accounting for up to 43% of total execution time in our benchmark set. On symbolic object-oriented code, late binding of function and method calls costs up to 30%. Redundant reference counting, dynamic type checks, and Python's elaborate function calling convention have comparatively smaller costs.

References

[1]
{Bar13} Gergö Barany. Static and dynamic method unboxing for Python. In 6. Arbeitstagung Programmiersprachen (ATPS 2013), number 215 in Lecture Notes in Informatics, 2013.
[2]
{Bar14} Gergö Barany. pylibjit: A JIT compiler library for Python. In Software Engineering 2014 (Workshops), number 1129 in CEUR Workshop Proceedings, 2014.
[3]
{BCFR09} Carl Friedrich Bolz, Antonio Cuni, Maciej Fijalkowski, and Armin Rigo. Tracing the meta-level: PyPy's tracing JIT compiler. In Proceedings of the 4th workshop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems, ICOOOLPS '09, pages 18--25, New York, NY, USA, 2009. ACM.
[4]
{Bru10a} Stefan Brunthaler. Efficient interpretation using quickening. In Proceedings of the 6th symposium on Dynamic languages, DLS '10, pages 1--14, New York, NY, USA, 2010. ACM.
[5]
{Bru10b} Stefan Brunthaler. Inline caching meets quickening. In Proceedings of the 24th European conference on Object-oriented programming, ECOOP'10, pages 429--451. Springer, 2010.
[6]
{Bru13} Stefan Brunthaler. Speculative staging for interpreter optimization. CoRR, http://arxiv.org/abs/1310.2300, 2013.
[7]
{HH09} Alex Holkner and James Harland. Evaluating the dynamic behaviour of Python applications. In Bernard Mans, editor, ACSC, volume 91 of CRPIT, pages 17--25. Australian Computer Society, 2009.
[8]
{MG11} Jason McCandless and David Gregg. Optimizing interpreters by tuning opcode orderings on virtual machines for modern architectures: Or: How I learned to stop worrying and love hill climbing. In Proceedings of the 9th International Conference on Principles and Practice of Programming in Java, PPPJ '11, pages 161--170. ACM, 2011.
[9]
{MKC+10} Nagy Mostafa, Chandra Krintz, Calin Cascaval, David Edelsohn, Priya Nagpurkar, and Peng Wu. Understanding the potential of interpreter-based optimizations for Python. Technical Report 2010-14, UCSB, 2010.
[10]
{num} numba: NumPy aware dynamic Python compiler using LLVM. https://github.com/numba/numba.
[11]
{PR13} Russell Power and Alex Rubinsteyn. How fast can we make interpreted Python? CoRR, http://arxiv.org/abs/1306.6047, 2013.
[12]
{Sel09} Dag Sverre Seljebotn. Fast numerical computations with Cython. In Proceedings of the 8th Python in Science conference (SciPy 2009), 2009.
[13]
{VSB} Michael M. Vitousek, Jeremy G. Siek, and Jim Baker. Design and evaluation of gradual typing for Python. http://wphomes.soic.indiana.edu/jsiek/files/2014/03/retic-python.pdf. {Online draft; accessed April 4, 2014}.

Cited By

View all
  • (2024)Application of an Artificial Neural Network for Efficient Computation of Chemical Activities within an EAF Process ModelMetals10.3390/met1406073614:6(736)Online publication date: 20-Jun-2024
  • (2024)Dr Wenowdis: Specializing Dynamic Language C Extensions using Type InformationProceedings of the 13th ACM SIGPLAN International Workshop on the State Of the Art in Program Analysis10.1145/3652588.3663316(1-8)Online publication date: 20-Jun-2024
  • (2023)Faster or Slower? Performance Mystery of Python Idioms Unveiled with Empirical Evidence2023 IEEE/ACM 45th International Conference on Software Engineering (ICSE)10.1109/ICSE48619.2023.00130(1495-1507)Online publication date: May-2023
  • Show More Cited By

Index Terms

  1. Python Interpreter Performance Deconstructed

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Conferences
    Dyla'14: Proceedings of the Workshop on Dynamic Languages and Applications
    June 2014
    45 pages
    ISBN:9781450329163
    DOI:10.1145/2617548
    Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

    Sponsors

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 09 June 2014

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. Python
    2. dynamic programming languages
    3. interpreters
    4. reference counting
    5. unboxing

    Qualifiers

    • Tutorial
    • Research
    • Refereed limited

    Conference

    PLDI '14
    Sponsor:

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)72
    • Downloads (Last 6 weeks)6
    Reflects downloads up to 04 Oct 2024

    Other Metrics

    Citations

    Cited By

    View all
    • (2024)Application of an Artificial Neural Network for Efficient Computation of Chemical Activities within an EAF Process ModelMetals10.3390/met1406073614:6(736)Online publication date: 20-Jun-2024
    • (2024)Dr Wenowdis: Specializing Dynamic Language C Extensions using Type InformationProceedings of the 13th ACM SIGPLAN International Workshop on the State Of the Art in Program Analysis10.1145/3652588.3663316(1-8)Online publication date: 20-Jun-2024
    • (2023)Faster or Slower? Performance Mystery of Python Idioms Unveiled with Empirical Evidence2023 IEEE/ACM 45th International Conference on Software Engineering (ICSE)10.1109/ICSE48619.2023.00130(1495-1507)Online publication date: May-2023
    • (2023)A memory footprint optimization framework for Python applications targeting edge devicesJournal of Systems Architecture10.1016/j.sysarc.2023.102936142(102936)Online publication date: Sep-2023
    • (2023)Python meets JIT compilers: A simple implementation and a comparative evaluationSoftware: Practice and Experience10.1002/spe.326754:2(225-256)Online publication date: 5-Sep-2023
    • (2022)RegCPython: A Register-based Python Interpreter for Better PerformanceACM Transactions on Architecture and Code Optimization10.1145/356897320:1(1-25)Online publication date: 16-Dec-2022
    • (2022)A fast in-place interpreter for WebAssemblyProceedings of the ACM on Programming Languages10.1145/35633116:OOPSLA2(646-672)Online publication date: 31-Oct-2022
    • (2022)Quantifying the interpretation overhead of PythonScience of Computer Programming10.1016/j.scico.2021.102759215:COnline publication date: 1-Mar-2022
    • (2021)A Surprisingly Simple Lua CompilerProceedings of the 25th Brazilian Symposium on Programming Languages10.1145/3475061.3475077(1-8)Online publication date: 27-Sep-2021
    • (2018)A Methodology for Optimization of Interpreters2018 Symposium on High Performance Computing Systems (WSCAD)10.1109/WSCAD.2018.00040(205-212)Online publication date: Oct-2018
    • Show More Cited By

    View Options

    Get Access

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media