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

LBYL 与 EAFP 漫谈(一点思考)

  •  
  •   scriptB0y ·
    laixintao · Aug 26, 2018 · 2690 views
    This topic created in 2854 days ago, the information mentioned may be changed or developed.
    5 replies    2018-08-27 10:00:03 +08:00
    whoami9894
        1
    whoami9894  
       Aug 26, 2018 via Android
    赞一个
    正则匹配中就喜欢 try + findall()[0]
    pabupa
        2
    pabupa  
       Aug 26, 2018 via Android
    我总以为异常捕获本身相对于提前检查是更耗费资源的😌
    scriptB0y
        3
    scriptB0y  
    OP
       Aug 26, 2018
    @pabupa 应该看具体情况吧,比如大多数情况异常都不发生,那么 catch 执行的次数少,catch 性能高。

    但是异常的次数很频繁,那么 catch 基本都会发生的情况下,可能 if 的性能就会高了(猜的)。
    yadam
        4
    yadam  
       Aug 27, 2018
    以前也搜了好多, 最后一句自个的话都没有, 只留下几个参考链接
    http://jialeicui.github.io/blog/EAFP_vs_LBYL.html
    scriptB0y
        5
    scriptB0y  
    OP
       Aug 27, 2018
    @yadam 资料很有用
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   917 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 49ms · UTC 23:01 · PVG 07:01 · LAX 16:01 · JFK 19:01
    ♥ Do have faith in what you're doing.