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

[讨论]Python 开始开发去 GIL 版本了吗?

  •  2
     
  •   janxin · May 29, 2016 via iPhone · 6491 views
    This topic created in 3639 days ago, the information mentioned may be changed or developed.
    今天,蟒爹转了一个 tweet ,一张图片,内容为

    https://twitter.com/gvanrossum/status/736632692784009216

    原推是一个叫做 GIL 切除术( gilectomy )的项目演讲照片,这是意味着 Python 从 3.6 版本开始有计划逐步去除 GIL 了吗?或者这还是一个 Python fork ?

    https://github.com/larryhastings/gilectomy

    Larry Hastings 也是 Python 贡献者之一。
    9 replies    2016-06-05 21:27:02 +08:00
    JhZ7z587cYROBgVQ
        1
    JhZ7z587cYROBgVQ  
       May 29, 2016
    不是说 2.2 还是哪个版本有一个去 gil 的分支么,然后测下来性能反而更悲剧了
    congeec
        2
    congeec  
       May 29, 2016
    消息刚出,反应还不是很热烈
    等会 Slideshare 上有了 PPT , Hack News 上面有讨论就好玩儿了
    2225377fjs
        3
    2225377fjs  
       May 29, 2016
    去 GIL , Python 生产环境会有更多的坑的, Java 踩过的坑 Python 都会再踩一遍, Java 发展了这么多年才有现在稳定的并行架构, Python 也不太可能一蹴而就。 GIL 被吐槽了这么多年,要是真没了,还真有可能不习惯。
    neoblackcap
        4
    neoblackcap  
       May 29, 2016
    GIL 出去不是什么大问题,性能下降有很多原因,不仅仅是 GIL 移除的问题。
    移除 GIL 最大的问题是很有可能会引起现有的 c 扩展都挂了,因为那很有可能会改动 cpython 的 c api 。
    其实按道理来说移除 GIL ,引入颗粒度更小的锁,用基于可达性分析的 GC 来替代朴素引用计数都基本上是现代高级语言的做法。
    至于 Python 界不是没有移除 GIL 的实现,一个很好的例子就是 Pypy ,那个可是没有 GIL 的,性能杠杠,还能真多线程。
    janxin
        5
    janxin  
    OP
       May 29, 2016   ❤️ 1
    @neoblackcap 如果我没记错 pypy 是有 GIL 的...
    dreampuf
        6
    dreampuf  
       May 29, 2016
    @neoblackcap

    http://doc.pypy.org/en/latest/faq.html#does-pypy-have-a-gil-why

    > Does PyPy have a GIL? Why?
    > Yes, PyPy has a GIL. Removing the GIL is very hard. The problems are essentially the same as with CPython (including the fact that our garbage collectors are not thread-safe so far). Fixing it is possible, as shown by Jython and IronPython, but difficult. It would require adapting the whole source code of PyPy, including subtle decisions about whether some effects are ok or not for the user (i.e. the Python programmer).

    > Instead, since 2012, there is work going on on a still very experimental Software Transactional Memory (STM) version of PyPy. This should give an alternative PyPy which works without a GIL, while at the same time continuing to give the Python programmer the complete illusion of having one.
    neoblackcap
        7
    neoblackcap  
       May 29, 2016
    @janxin 对,刚查了一下, pypy 是有 GIL 的, pypy stm 才没有 GIL
    janxin
        8
    janxin  
    OP
       Jun 2, 2016
    演讲视频
    v0768ex
        9
    v0768ex  
       Jun 5, 2016 via Android
    去掉 gil 容易扯到蛋,几年内看不到希望。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2508 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 00:30 · PVG 08:30 · LAX 17:30 · JFK 20:30
    ♥ Do have faith in what you're doing.