3 ms·
One problem is that because of the GIL, many python libraries don't use locking on their data, etc., because they don't need to. That makes them thread-unsafe w
by glandium 7y ago
One problem is that because of the GIL, many python libraries don't use locking on their data, etc., because they don't need to. That makes them thread-unsafe without the GIL.
- zaphirplane 7y agoYou mean libraries with c extensions
- ehsankia 7y agoYes, getting rid of the GIL breaks most c extensions, many of which are very important.
- glandium 7y agoNo, even libraries without. Picking something random in the python 3.7 standard library: collections.OrderedDict.__setitem__ doesn't look thread-safe when it updates its linked list. EDIT: well, in fact, the data race in that one is there whether there is a GIL or not...
- xapata 7y agoJust FYI, there are few remaining use cases for OrderedDict, now that built-in dict keeps insertion order.
- ris 7y agoIf you look more closely, it often makes them thread-unsafe even with the GIL. Take a look some time at what operations the GIL can pre-empt a python thread in the middle of.