News for hackers. Stuff that matters.
Re:Meta pledges Three-Year sponsorship for Python if GIL rem... by bsder on Saturday July 08, 2023 @05:26PM (#36648940)
> This vastly understates the work involved. Most C extensions and embeddings will require major structural changes or even rewrites.

Why?

Once you have a threaded Python, you can allocate one thread to run with a GIL and the other threads without it. Old extensions can access one thread with the old GIL API and new extensions can access all the things with the GIL-less API.

People who want the performance will rewrite their extension. People who don't, won't.

Re:Meta pledges Three-Year sponsorship for Python if GIL rem... by tsukikage on Saturday July 08, 2023 @06:08PM (#36649276)
That's not quite good enough - people use threads to e.g. permit multiple blocking i/o operations to be in flight at once, which works perfectly well right now. So you're going to want to support multiple GIL threads if you want to be able to support existing code safely.

Sadly, you can't just trivially bolt on thread safety to code that was not designed with it in mind.

However, if you go the other way and introduce e.g. an @nogil decorator, similar to that seen in some cpython alternatives, people will have a straightforward path to opt in incrementally as they fix and verify the critical parts of their code, while preserving known working behaviour elsewhere without having to throw entire complex systems over the wall at once.

Re:Meta pledges Three-Year sponsorship for Python if GIL rem... by schmeii on Tuesday July 11, 2023 @12:30PM (#36683371)
I don't think that is possible to activate the GIL only for one thread, it has to be activated process-wide.

But, if you want free-threading but you have to use an old extension that is not GIL-less, then you still can, by garding all access to this extension with a lock and setting the PYTHONGIL variable to 0.

But, you will need to compile the extension with --disable-gil or to obtain that from somewhere, if the extension author doesn't provide it, as the ABI of "standard" python and "--disable-gil" python is different.

How --disable-gil builds of python and of extensions will be distributed is not yet totally clear. I don't think pypi has already a clear idea of how to handle those extension, for instance.