Empirical Analysis of Python’s Energy Impact: Evidence from Real Measurements
- Instituto de Tecnologı́as y Sistemas de Información Camino de Moledores
s/n, 13005, Ciudad Real, Spain
{elisa.jimenez,alberto.gordillo,coral.calero,mariaangeles.moraga,felix.garcia}@uclm.es
Abstract
Background: Programming languages provide the notation for writing computer programs capable of granting our devices the desired functionalities. Even though they may seem intangible, the resulting programs involve an amount of energy consumption, which has an impact on the environment. Some studies on the consumption of programming languages indicate that while being one of the most widely used languages, Python is also one of the most demanding in terms of energy consumption. Aims: To provide developers using Python with a set of best practices on how to use it in the most energy-efficient way, this paper presents a study on whether the different ways of programming in Python have an impact on the energy consumption of the resulting programs. Method: We have studied the relationship between Python’s energy consumption and the fact that Python is a very versatile language that allows programs to be compiled and executed in many different ways. Results: From the results obtained in our study, there seems to be a clear relationship between software energy consumption at runtime and: (1) the use of interpreted or compiled Python; (2) the use of dynamically or statically typed variables. Conclusions: Compiling Python code is a good option if it is done using the py compile module. The use of interpreted code seems to decrease energy consumption over compiling using Nuitka. The use of dynamically typed variables seems to decrease considerably the graphics and processor energy consumption. In addition, we have observed that energy consumption is not always directly related to execution time. Sometimes, more power in less time increases consumption, due to the power required.
Key words
python, efficiency, programming languages, green software
How to cite
Jimenez, E., Gordillo, A., Calero, C., Moraga, M. Á., Garcı́a, F.: Empirical Analysis of Python’s Energy Impact: Evidence from Real Measurements. Computer Science and Information Systems