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
janxin
V2EX  ›  Python

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

  •  2
     
  •   janxin · 2016-05-29 09:46:23 +08:00 via iPhone · 5745 次点击
    这是一个创建于 2893 天前的主题,其中的信息可能已经有所发展或是发生改变。
    今天,蟒爹转了一个 tweet ,一张图片,内容为

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

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

    https://github.com/larryhastings/gilectomy

    Larry Hastings 也是 Python 贡献者之一。
    9 条回复    2016-06-05 21:27:02 +08:00
    jason0916
        1
    jason0916  
       2016-05-29 10:03:01 +08:00
    不是说 2.2 还是哪个版本有一个去 gil 的分支么,然后测下来性能反而更悲剧了
    congeec
        2
    congeec  
       2016-05-29 10:17:22 +08:00
    消息刚出,反应还不是很热烈
    等会 Slideshare 上有了 PPT , Hack News 上面有讨论就好玩儿了
    2225377fjs
        3
    2225377fjs  
       2016-05-29 12:36:30 +08:00
    去 GIL , Python 生产环境会有更多的坑的, Java 踩过的坑 Python 都会再踩一遍, Java 发展了这么多年才有现在稳定的并行架构, Python 也不太可能一蹴而就。 GIL 被吐槽了这么多年,要是真没了,还真有可能不习惯。
    neoblackcap
        4
    neoblackcap  
       2016-05-29 13:54:21 +08:00
    GIL 出去不是什么大问题,性能下降有很多原因,不仅仅是 GIL 移除的问题。
    移除 GIL 最大的问题是很有可能会引起现有的 c 扩展都挂了,因为那很有可能会改动 cpython 的 c api 。
    其实按道理来说移除 GIL ,引入颗粒度更小的锁,用基于可达性分析的 GC 来替代朴素引用计数都基本上是现代高级语言的做法。
    至于 Python 界不是没有移除 GIL 的实现,一个很好的例子就是 Pypy ,那个可是没有 GIL 的,性能杠杠,还能真多线程。
    janxin
        5
    janxin  
    OP
       2016-05-29 14:07:25 +08:00   ❤️ 1
    @neoblackcap 如果我没记错 pypy 是有 GIL 的...
    dreampuf
        6
    dreampuf  
       2016-05-29 14:18:25 +08:00
    @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  
       2016-05-29 14:19:50 +08:00
    @janxin 对,刚查了一下, pypy 是有 GIL 的, pypy stm 才没有 GIL
    janxin
        8
    janxin  
    OP
       2016-06-02 15:12:24 +08:00
    演讲视频
    v0768ex
        9
    v0768ex  
       2016-06-05 21:27:02 +08:00 via Android
    去掉 gil 容易扯到蛋,几年内看不到希望。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3457 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 04:41 · PVG 12:41 · LAX 21:41 · JFK 00:41
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.