V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
a33486
V2EX  ›  Python

小白求教大神引入模块哪种性能更高

  •  
  •   a33486 · 2018-04-12 15:01:16 +08:00 · 1600 次点击
    这是一个创建于 2177 天前的主题,其中的信息可能已经有所发展或是发生改变。
    __important__(‘ random ’).randint 导入模块函数只能用一次,from random important randint 是导入对应模块中的函数,两种写法那种性能更高?求大神指点?
    bookding0
        1
    bookding0  
       2018-04-12 16:21:28 +08:00   ❤️ 1
    1. important -> import
    2. from random import randint 等价于 randint = __import__('random').randint
    3.你可以理解为性能没区别
    4.Python 比较 CPU 性能没什么太大意义,高并发下 io 性能才是需要考虑的。
    julyclyde
        2
    julyclyde  
       2018-04-13 10:36:49 +08:00
    important ……
    楼主建议还是先学一下英语,别在性能高低这种有的没的问题上浪费时间
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2718 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 15:41 · PVG 23:41 · LAX 08:41 · JFK 11:41
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.