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
Post a Comment