profiling - Why is a function/method call in python expensive? -


in this post, guido van rossum says function call may expensive, not understand why nor how expensive can be.

how delay adds code simple function call , why?

a function call requires current execution frame suspended, , new frame created , pushed on stack. relatively expensive, compared many other operations.

you can measure exact time required timeit module:

>>> import timeit >>> def f(): pass ...  >>> timeit.timeit(f) 0.15175890922546387 

that's 1/6th of second million calls empty function; you'd compare time required whatever thinking of putting in function; 0.15 second need taken account, if performance issue.


Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -