5 ms·
Thank you! That makes sense, and it also explains why removing the GIL has a negative performance impact as discussed in other comments. Taking a lock every tim
by FartyMcFarter 3y ago
Thank you! That makes sense, and it also explains why removing the GIL has a negative performance impact as discussed in other comments. Taking a lock every time a container is accessed is significant overhead, which is why languages like C++ don't make basic containers thread-safe.
- ska 3y agoEffectively the GIL is incurring that overhead on every data structure whether you need it or not. But with it removed, you'll have to think about it in your designs more than currently. History shows us this is not easy.
- FartyMcFarter 3y ago> Effectively the GIL is incurring that overhead on every data structure whether you need it or not. Not really. The GIL is taken and released quite infrequently (only when the Python interpreter decides it's time to do a context switch), whilst the new locks for each data structure are taken/released every time you do a basic operation on those data structures. Holding a lock that is rarely taken/released incurs very little overhead.
- ska 3y agoHm, that’s a fair point, it’s only some of the same overhead because it’s not per operation.