python - Is one faster than another? func() or module.func() -


i see from x import * discouraged on place. corrupts naming space, etc.

so i'm inclined use from . import x, , when need use functions, i'll call x.func() instead of using func().

the speed difference little, still want know how might impact performance? can keep habit without needing worry other things.

it has practically no impact:

>>> import timeit >>> timeit.timeit('math.pow(1, 1)', 'import math') 0.20310196322982677 >>> timeit.timeit('pow(1, 1)', 'from math import pow') 0.19039931574786806 

note picked function have little run time difference magnified.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -