推荐学习书目
› 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
398.47D
568.07D
V2EX  ›  Python

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

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

    ```python
    import socket

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