News for hackers. Stuff that matters.
Re:The Changing "Guarantees" Given by Python's Global Interp... by dfox on Friday November 17, 2023 @09:58AM (#38304419)
You can probably trigger the behavior of random interleaving even with GIL if you use something other than list or tuple as an argument to list.extend(). CPython special cases list and tuples and copies the contents directly (list_extend_fast() in listobject.c) while it uses iterator for other types (list_extend_iter()).

Because the iterator can be pretty much arbitrary Python code it seems to be a bad idea to guarantee extend() to be atomic, as you don't want to hold the list mutex while calling out into user code.

Re:The Changing "Guarantees" Given by Python's Global Interp... by nerdponx on Friday November 17, 2023 @10:16AM (#38304705)
All the more reason to wonder. What's going to be special-cased to become atomic and thread-safe, and what won't be?

A surprising amount of the CPython stdlib is just pure Python code.