4 ms·
I know this is a joke, but you still need locks in Python
by josalhor 7y ago
I know this is a joke, but you still need locks in Python
- bch 7y agoTheoretically not necessarily the referenced GIL, though. There are conceptually alternative models; see Microsoft doc[0] on apartment threading model, or Tcl[1]. [0] https://docs.microsoft.com/en-us/windows/win32/com/processes--threads--and-apartments https://docs.microsoft.com/en-us/windows/win32/com/processes... [1] https://stackoverflow.com/questions/45799121/runtimeerror-calling-tcl-from-different-appartment-tkinter-and-threading#45803955 https://stackoverflow.com/questions/45799121/runtimeerror-ca...
- ajross 7y agoI didn't read it as a joke, you're just operating at a different abstraction level. The CPython interpreter famously uses a single global interpreter lock to protect the language internals and runtime, so it has trouble scaling beyond a single CPU on interpreter-heavy workloads. You're saying that threads in python scripts can be arbitrarily preempted, and so locking is required to protect them against each other, which is also true.