1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Python/RubyのGILはC-Extension実行中は遷移しない

Last updated at Posted at 2022-03-02

Python

sleep start
hello # main-thread's hello can be executed during time.sleep(3)
sleep end
sleep start
sleep end
hello # pybind11_playground.toyclass().sleep(3) blocks executing main-thread's hello

Ruby

sleep start
hello # main-thread's hello can be executed during sleep(3)
hello
hello
hello
hello
sleep end
sleep start
hello # took 3 secs to show the first hello; RicePlayground::ToyClass.new.sleep(3) blocks execution
sleep end
hello
hello
hello
hello

結論

表題のとおりです。これが意味するところは、 Python/Ruby側にexportされていないC-Ext内だけで完結しているコードに関しては、競合状態は考慮する必要がないということです。

(たとえばvectorを0からsize()-1まで走査する場合にsizeが変わる可能性があるとか、そういう話)

C-Extはまだまだ難しいなぁ^^;;;

1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?