推荐学习书目
› 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
Livid
403.84D
566.44D
V2EX  ›  Python

Python 代码中的未使用的 import 会有哪些负面影响呢?

  •  
  •   Livid ·
    PRO
    · Jul 17, 2014 via iPhone · 6175 views
    This topic created in 4495 days ago, the information mentioned may be changed or developed.
    10 replies  •  2014-07-18 14:26:05 +08:00
    JohnDeng
    JohnDeng
    Jul 17, 2014
    2
    编译的时候多一些无用指令。
    xingzhi
    xingzhi
    Jul 17, 2014
    3
    如果被import的文件在函数体外还有执行语句或者有其它依赖的话,会带来不必要的麻烦。
    tonyluj
    tonyluj
    Jul 17, 2014
    4
    所以在Go语言中,无效的import 会直接报错~~~
    siteshen
    siteshen
    Jul 17, 2014❤️1
    5
    过不了flake8又能简单fix的东西都要fix。
    phuslu
    phuslu
    Jul 17, 2014❤️1
    6
    坚决不能 import, 会增大内存占用。尤其是 virt 占用。
    clino
    clino
    Jul 18, 2014
    7
    像ulipad就有提示未使用的import的功能,我觉得主要不好的地方还是内存占用吧
    xiaket
    xiaket
    Jul 18, 2014
    8
    import不仅仅是占用内存. import一个模块的时候可能会执行过一些代码, 万一这些执行的代码会对整个程序运行有不良影响就挂了.
    zzcflying
    zzcflying
    Jul 18, 2014
    9
    楼上说的好可怕。好怕怕呀。
    cj1324
    cj1324
    Jul 18, 2014
    10
    嘿嘿 我见过不少
    xxx.py

    ```python
    import socket

    socket.setdefaulttimeout(15)
    ```
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2268 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 12:19 · PVG 20:19 · LAX 04:19 · JFK 07:19
    ♥ Do have faith in what you're doing.