2

Python 的原生 multithreading 支援

 1 year ago
source link: https://blog.gslin.org/archives/2023/05/16/11187/python-%e7%9a%84%e5%8e%9f%e7%94%9f-multithreading-%e6%94%af%e6%8f%b4/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Python 的原生 multithreading 支援

Simon Willison 這邊看到的:「Real Multithreading is Coming to Python - Learn How You Can Use It Now」,他引用的原文在「Real Multithreading is Coming to Python - Learn How You Can Use It Now」這邊,在講 Python 3.12 將會有原生 multithreading 支援。

Python 裡知名的 GIL 問題將會用 Per-Interpreter GIL 的技術來解決,把 GIL 的 global-based 改寫變成 thread-based:

With introduction of "Per-Interpreter GIL", individual Python interpreters don't share the same GIL anymore. This level of isolation allows each of these sub-interpreters to run really concurrently.

這算是基礎建設,之後應該會有蠻長的陣痛期要轉換,尤其是各個其他程式語言寫的 library 要考慮到 thread-safe 的問題。

話說回來,PHP 就沒繼續討論過 threading 這個問題了,大家還是繼續用 process 架構在搞 XD

Related

Multithreading 版本 pt-online-schema-change

看起來是個嘗試,Percona 的人試著修改 pt-online-schema-change,讓他可以在 INSERT 時 multi-threading,然後看效果:「Multithreaded ALTER TABLE with pt-online-schema-change and myloader」。 可以看出來 thread 夠多的情況下其實都變快不少 (上圖主要是看絕對數字,下圖是看相對比率): 如果沒有意外的話應該會有更多的測試,而這些測試沒問題的話,之後的官方版本裡面應該就會有這個功能。

May 15, 2020

In "Computer"

Google 弄出來的 Grumpy:把 Python 2.7 的程式碼轉成 Go...

Google 放出 Grumpy,可以把 Python 2.7 的程式碼轉成 Go:「Grumpy: Go running Python!」。 下面看到一個留言頗有趣的: This sad to see that Grumpy is mean to be a replacement of CPython 2.7 instead of CPython 3.x . I presume the code from youtube was written in python 2.x hence the reason but I hope we'll see…

January 8, 2017

In "Computer"

HipHop for PHP 計畫

由 HipHop for PHP project 的幾位帶領者所說明的會議中解釋了不少東西 (在 USTREAM 有錄影可以觀看:Facebook Technology Tasting - HipHop for PHP)。 前半部份等於是把「HipHop for PHP: Move Fast」重講一次,並且說明他們在不少 case 下可以分析出 variable type,所以不需要用 zval (一般性的變數)。 比較重要的是後半段的 Q&A 部份。 就會場所提到的,他們目前跑在 Apache 1.3 + prefork 上面。有計劃要支援 multithreading,好處是 shared resource 可以共用,像是 database connection,但解法是苦工 (修正所有 thread-safe 的問題)。而既有的 extension (包括他們自己寫的) 則是維持相容,這應該是指維持 PHP extension 介面相容性。…

February 4, 2010

In "Computer"

a611ee8db44c8d03a20edf0bf5a71d80?s=49&d=identicon&r=gAuthor Gea-Suan LinPosted on May 16, 2023Categories Computer, Murmuring, Programming, SoftwareTags gil, multi, multithreading, native, python, thread, threading

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment *

Name *

Email *

Website

Notify me of follow-up comments by email.

Notify me of new posts by email.

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Learn More)

Post navigation


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK