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

2016-05-29 09:46:23 +08:00
 janxin
今天,蟒爹转了一个 tweet ,一张图片,内容为

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

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

https://github.com/larryhastings/gilectomy

Larry Hastings 也是 Python 贡献者之一。
5745 次点击
所在节点    Python
9 条回复
jason0916
2016-05-29 10:03:01 +08:00
不是说 2.2 还是哪个版本有一个去 gil 的分支么,然后测下来性能反而更悲剧了
congeec
2016-05-29 10:17:22 +08:00
消息刚出,反应还不是很热烈
等会 Slideshare 上有了 PPT , Hack News 上面有讨论就好玩儿了
2225377fjs
2016-05-29 12:36:30 +08:00
去 GIL , Python 生产环境会有更多的坑的, Java 踩过的坑 Python 都会再踩一遍, Java 发展了这么多年才有现在稳定的并行架构, Python 也不太可能一蹴而就。 GIL 被吐槽了这么多年,要是真没了,还真有可能不习惯。
neoblackcap
2016-05-29 13:54:21 +08:00
GIL 出去不是什么大问题,性能下降有很多原因,不仅仅是 GIL 移除的问题。
移除 GIL 最大的问题是很有可能会引起现有的 c 扩展都挂了,因为那很有可能会改动 cpython 的 c api 。
其实按道理来说移除 GIL ,引入颗粒度更小的锁,用基于可达性分析的 GC 来替代朴素引用计数都基本上是现代高级语言的做法。
至于 Python 界不是没有移除 GIL 的实现,一个很好的例子就是 Pypy ,那个可是没有 GIL 的,性能杠杠,还能真多线程。
janxin
2016-05-29 14:07:25 +08:00
@neoblackcap 如果我没记错 pypy 是有 GIL 的...
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
2016-05-29 14:19:50 +08:00
@janxin 对,刚查了一下, pypy 是有 GIL 的, pypy stm 才没有 GIL
janxin
2016-06-02 15:12:24 +08:00
<amp-youtube data-videoid="P3AyI_u66Bw" layout="responsive" width="480" height="270"></amp-youtube> 演讲视频
v0768ex
2016-06-05 21:27:02 +08:00
去掉 gil 容易扯到蛋,几年内看不到希望。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/281970

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX