skip to main content
10.1145/3623476.3623529acmconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
research-article
Artifacts Available / v1.1

An Executable Semantics for Faster Development of Optimizing Python Compilers

Published:23 October 2023Publication History
Related Artifact: semPY software https://doi.org/10.1145/3580421

ABSTRACT

Python is a popular programming language whose performance is known to be uncompetitive in comparison to static languages such as C. Although significant efforts have already accelerated implementations of the language, more efficient ones are still required. The development of such optimized implementations is nevertheless hampered by its complex semantics and the lack of an official formal semantics. We address this issue by presenting an approach to define an executable semantics targeting the development of optimizing compilers. This executable semantics is written in a format that highlights type checks, primitive values boxing and unboxing, and function calls, which are all known sources of overhead. We also present semPy, a partial evaluator of our executable semantics that can be used to remove redundant operations when evaluating arithmetic operators. Finally, we present Zipi, a Python optimizing compiler prototype developed with the aid of semPy. On some tasks, Zipi displays performance competitive with that of state-of-the-art Python implementations.

References

  1. Davide Ancona, Massimo Ancona, Antonio Cuni, and Nicholas D. Matsakis. 2007. RPython: A Step towards Reconciling Dynamically and Statically Typed OO Languages. In Proceedings of the 2007 Symposium on Dynamic Languages (DLS ’07). New York, NY, USA. 53–64. isbn:978-1-59593-868-8 https://doi.org/10.1145/1297081.1297091 Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Martin Bodin, Arthur Chargueraud, Daniele Filaretti, Philippa Gardner, Sergio Maffeis, Daiva Naudziuniene, Alan Schmitt, and Gareth Smith. 2014. A Trusted Mechanised JavaScript Specification. In Proceedings of the 41st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’14). 87–100. isbn:9781450325448 https://doi.org/10.1145/2535838.2535876 Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Martin Bodin, Tomás Diaz, and Éric Tanter. 2020. A Trustworthy Mechanized Formalization of R. SIGPLAN Not., 53, 8 (2020), apr, 13–24. issn:0362-1340 https://doi.org/10.1145/3393673.3276946 Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Denis Bogdanas and Grigore Roşu. 2015. K-Java: A Complete Semantics of Java. SIGPLAN Not., 50, 1 (2015), jan, 445–456. issn:0362-1340 https://doi.org/10.1145/2775051.2676982 Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Carl Friedrich Bolz, Antonio Cuni, Maciej Fijalkowski, and Armin Rigo. 2009. 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). 18–25. isbn:9781605585413 https://doi.org/10.1145/1565824.1565827 Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Dybvig, Kent. 2009. The Scheme Programming Language (fourth edition ed.). The MIT Press. isbn:978-0-262-51298-5 https://www.scheme.com/tspl4/ Google ScholarGoogle Scholar
  7. Chucky Ellison and Grigore Rosu. 2012. An Executable Formal Semantics of C with Applications. In Proceedings of the 39th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’12). 533–544. isbn:9781450310833 https://doi.org/10.1145/2103656.2103719 Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Marc Feeley and Marc-André Bélanger. 2023. Forensics. https://github.com/udem-dlteam/forensics/ Google ScholarGoogle Scholar
  9. Marc Feeley and Marc-André Bélanger. 2023. Zipi Forensics. https://zipi-forensics.gambitscheme.org/ Google ScholarGoogle Scholar
  10. Feeley, Marc. 2023. Gambit. https://www.iro.umontreal.ca/ gambit/doc/gambit.pdf Google ScholarGoogle Scholar
  11. Daniele Filaretti and Sergio Maffeis. 2014. An Executable Formal Semantics of PHP. In ECOOP 2014 – Object-Oriented Programming, Richard Jones (Ed.). 567–592. isbn:978-3-662-44202-9 Google ScholarGoogle Scholar
  12. Gouy, Isaac. 2023. The Computer Language Benchmarks Game. https://benchmarksgame-team.pages.debian.net/benchmarksgame/ Google ScholarGoogle Scholar
  13. Michael Greenberg and Austin J. Blatt. 2019. Executable Formal Semantics for the POSIX Shell. Proc. ACM Program. Lang., 4, POPL (2019), Article 43, dec, 30 pages. https://doi.org/10.1145/3371111 Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Mohamed Ismail and G. Suh. 2018. Quantitative Overhead Analysis for Python. In 2018 IEEE International Symposium on Workload Characterization (IISWC). Raleigh, NC, USA. 36–47. https://doi.org/10.1109/IISWC.2018.8573512 Google ScholarGoogle ScholarCross RefCross Ref
  15. Olivier Melançon. 2022. Reusable Semantics for Implementation of Python Optimizing Compilers. https://papyrus.bib.umontreal.ca/xmlui/handle/1866/26538 Google ScholarGoogle Scholar
  16. Olivier Melançon. 2023. semPy. https://doi.org/10.1145/3580421 Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Raphaël Monat, Abdelraouf Ouadjaout, and Antoine Miné. 2020. Static Type Analysis by Abstract Interpretation of Python Programs. In 34th European Conference on Object-Oriented Programming (ECOOP 2020), Robert Hirschfeld and Tobias Pape (Eds.) (Leibniz International Proceedings in Informatics (LIPIcs), Vol. 166). Schloss Dagstuhl– Leibniz-Zentrum für Informatik, Dagstuhl, Germany. 17:1–17:29. isbn:978-3-95977-154-2 issn:1868-8969 https://doi.org/10.4230/LIPIcs.ECOOP.2020.17 Google ScholarGoogle ScholarCross RefCross Ref
  18. Peter D. Mosses. 1975. Mathematical semantics and compiler generation. University of Oxford. https://ethos.bl.uk/OrderDetails.do?uin=uk.bl.ethos.466424 Google ScholarGoogle Scholar
  19. Peter D. Mosses. 1996. Theory and Practice of Action Semantics. MFCS ’96, 1113, 37–61. isbn:978-3-540-61550-7 https://doi.org/10.1007/3-540-61550-4_139 Google ScholarGoogle ScholarCross RefCross Ref
  20. Mozilla. 2023. Primitive. https://developer.mozilla.org/en-US/docs/Glossary/Primitive Google ScholarGoogle Scholar
  21. Joe Gibbs Politz, Alejandro Martinez, Matthew Milano, Sumner Warren, Daniel Patterson, Junsong Li, Anand Chitipothu, and Shriram Krishnamurthi. 2013. Python: The Full Monty — A Tested Semantics for the Python Programming Language. In Proceedings of the 2013 ACM SIGPLAN International Conference on Object Oriented Programming Systems Languages & Applications (OOPSLA ’13). New York, NY, USA. 217–232. isbn:978-1-4503-2374-1 https://doi.org/10.1145/2509136.2509536 Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Serrano, Manuel. 2023. Bigloo. https://www-sop.inria.fr/mimosa/fp/Bigloo Google ScholarGoogle Scholar
  23. Simionato, Michele. 2023. The Python 2.3 Method Resolution Order. https://www.python.org/download/releases/2.3/mro Google ScholarGoogle Scholar
  24. Mallku Soldevila, Beta Ziliani, and Bruno Silvestre. 2022. From Specification to Testing: Semantics Engineering for Lua 5.2. J. Autom. Reason., 66, 4 (2022), nov, 905–952. issn:0168-7433 https://doi.org/10.1007/s10817-022-09638-y Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Stinner, Victor. 2023. Benchmarks — Python Performance Benchmark Suite. https://pyperformance.readthedocs.io/benchmarks.html Google ScholarGoogle Scholar
  26. Stinner, Victor. 2023. The Python Performance Benchmark Suite. https://pyperformance.readthedocs.io Google ScholarGoogle Scholar
  27. The PyPy Team. 2023. PyPy. https://www.pypy.org Google ScholarGoogle Scholar
  28. The Python Software Foundation. 2023. cPython 3.9. https://www.python.org Google ScholarGoogle Scholar
  29. The Python Software Foundation. 2023. Performance Options. https://docs.python.org/3/using/configure.html#performance-options Google ScholarGoogle Scholar
  30. The Python Software Foundation. 2023. PyPerformance. https://github.com/python/pyperformance Google ScholarGoogle Scholar
  31. The Python Software Foundation. 2023. The Python Language Reference. https://docs.python.org/3/reference/index.html Google ScholarGoogle Scholar
  32. TIOBE Software BV. 2023. TIOBE Index for August 2023. https://www.tiobe.com/tiobe-index/ Google ScholarGoogle Scholar
  33. Yannick Zakowski, Calvin Beck, Irene Yoon, Ilia Zaichuk, Vadim Zaliva, and Steve Zdancewic. 2021. Modular, Compositional, and Executable Formal Semantics for LLVM IR. Proc. ACM Program. Lang., 5, ICFP (2021), Article 67, aug, 30 pages. https://doi.org/10.1145/3473572 Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Qiang Zhang, Lei Xu, Xiangyu Zhang, and Baowen Xu. 2022. Quantifying the Interpretation Overhead of Python. Science of Computer Programming, 215, C (2022), March, issn:0167-6423 https://doi.org/10.1016/j.scico.2021.102759 Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. An Executable Semantics for Faster Development of Optimizing Python Compilers

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in
    • Article Metrics

      • Downloads (Last 12 months)65
      • Downloads (Last 6 weeks)9

      Other Metrics

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader