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