Does Python optimize function calls from loops?

后端 未结 5 524
不思量自难忘°
不思量自难忘° 2021-02-04 04:50

Say, I have a code which calls some function millions time from loop and I want the code to be fast:

def outer_function(file):
    for line in file:
        inne         


        
5条回答
  •  南方客
    南方客 (楼主)
    2021-02-04 05:13

    If by "Python" you mean CPython, the generally used implementation, no.

    If by "Python" you happened to mean any implementation of the Python language, yes. PyPy can optimise a lot and I believe its method JIT should take care of cases like this.

提交回复
热议问题