News for hackers. Stuff that matters.
Re:No-GIL mode coming for Python by mappu on Friday July 28, 2023 @06:52PM (#36914451)
With PEP703 you would compile Python either for multi or single-threading mode. The mode affects the ABI and therefore which C extensions are available. Eventually all C extensions would have an available port to the new ABI.

The chosen solution is similar to how PHP used TSRMLS_ macros in the Zend engine - if threadsafety (ZTS) was #defined, all functions took an extra thread context parameter, breaking ABI.

Re:No-GIL mode coming for Python by miraculixx on Friday July 28, 2023 @07:40PM (#36914894)
How did it work out for PHP?
Re:No-GIL mode coming for Python by no_wizard on Friday July 28, 2023 @08:03PM (#36915104)
Honestly it didn't. PHP didn't get threads. It did eventually get Fibers though, which I suppose may have been in part influenced by this work
Re:No-GIL mode coming for Python by mappu on Friday July 28, 2023 @09:45PM (#36915922)
The main benefit of the threadsafe builds was reentrancy support for multithreaded web servers (e.g. IIS / some apache MPMs). They were only slightly slower for single-threaded code.

The new PHP 8 fibers are only coroutines on a single thread, but PHP has had fork/join since 2001 (!), which works pretty well with Linux CoW.

There has been a pthreads extension since about 2012. However keeping a 1:1 pthreads API prevents some optimization possibilities [1], so the new hotness is php-parallel [2], which will transparently copy closed-over variables to a subinterpreter.

1. https://github.com/krakjoe/pthreads/issues/929#issue-4106367...

2. https://www.php.net/manual/en/philosophy.parallel.php

Re:No-GIL mode coming for Python by samus on Saturday July 29, 2023 @07:31AM (#36919180)
All C extensions are available when running without GIL. A challenge for distribution is that all extensions will have to built twice to be compatible with the two Python builds. However, few source code changes are required where the developers don't want to make it compatible with running without GIL. Executing such extensions forces using the GIL for the whole interpreter, which is slower than the GIL-only build.