2

In Python, only one thread can interact with the Interpreter. The GIL enforces this mechanism. This is to ensure thread safety. What are the reasons to not have one lock per mutable data and this lock has to be acquired to read/write to/from this data rather than have a GIL. This way, I think Python could still maintain some concurrency capacity

figs_and_nuts
  • 4,870
  • 2
  • 31
  • 56
  • 1
    To be clear GIL is **not** in the Python specification, it's an implementation detail of CPython. Jython and IronPython, for example, don't have the GIL. – Selcuk Jun 22 '21 at 03:46
  • Why is this question closed? The linked question has answers around why GIL is needed. This question asks specifically for the reasons for not endowing each mutable object with its own lock. – figs_and_nuts Jun 22 '21 at 06:34
  • The duplicate inherently asks the same question and the accepted answer by a well known Python expert, Alex Martelli, perfectly summarizes it (emphasis mine): _"CPython (the popular implementation) has always used a GIL **for ease of coding**"_. – Selcuk Jun 22 '21 at 06:42

0 Answers0