Python import X or from X import Y? (performance)

前端 未结 4 1362
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-30 03:39

If there is a library from which I\'m going to use at least two methods, is there any difference in performance or memory usage between the following?

from X         


        
4条回答
  •  执念已碎
    2020-11-30 04:22

    There is no memory or speed difference (the whole module has to be evaluated either way, because the last line could be Y = something_else). Unless your computer is from the 1980s it doesn't matter anyways.

提交回复
热议问题