The effect of unrolling and inlining for python bytecode optimizations

Yosi Ben Asher, Nadav Rotem

Research output: Chapter in Book/Report/Conference proceedingConference contributionpeer-review


In this study, we consider bytecode optimizations for Python, a programming language which combines object-oriented concepts with features of scripting languages, such as dynamic dictionaries. Due to its design nature, Python is relatively slow compared to other languages. It operates through compiling the code into powerful bytecode instructions that are executed by an interpreter. Python's speed is limited due to its interpreter design, and thus there is a significant need to optimize the language. In this paper, we discuss one possible approach and limitations in optimizing Python based on bytecode transformations. In the first stage of the proposed optimizer, the bytecode is expanded using function inline and loop unrolling. The second stage of transformations simplifies the bytecode by applying a complete set of data-flow optimizations, including constant propagation, algebraic simplifications, dead code elimination, copy propagation, common sub expressions elimination, loop invariant code motion and strength reduction. While these optimizations are known and their implementation mechanism (data flow analysis) is well developed, they have not been successfully implemented in Python due to its dynamic features which prevent their use. In this work we attempt to understand the dynamic features of Python and how these features affect and limit the implementation of these optimizations. In particular, we consider the significant effects of first unrolling and then inlining on the ability to apply the remaining optimizations. The results of our experiments indicate that these optimizations can indeed be implemented and dramatically improve execution times.

Original languageEnglish
Title of host publicationProceedings of the Israeli Experimental Systems Conference, SYSTOR 2009
Number of pages1
StatePublished - 2009
EventSYSTOR 2009: The Israeli Experimental Systems Conference - Haifa, Israel
Duration: 4 May 20096 May 2009

Publication series

NameACM International Conference Proceeding Series


ConferenceSYSTOR 2009: The Israeli Experimental Systems Conference


  • Bytecode Optimizations
  • Dynamic Languages
  • Python

ASJC Scopus subject areas

  • Software
  • Human-Computer Interaction
  • Computer Vision and Pattern Recognition
  • Computer Networks and Communications


Dive into the research topics of 'The effect of unrolling and inlining for python bytecode optimizations'. Together they form a unique fingerprint.

Cite this