Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Does it? The GIL only ensured each interpreter instruction is atomic. But any group of instruction is not protected. This makes it very hard to rely on the GIL for synchronization unless you really know what you are doing.


AFAIK a group of instructions is only non-protected if one of the instructions does I/O. Explicit I/O - page faults don't count.


If I understand that correctly, it would mean that running a function like this on two threads f(1) and f(2) would produce a list of 1 and 2 without interleaving.

  def f(x):
      for _ in range(N):
          l.append(x)
I've tried it out and they start interleaving when N is set to 1000000.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: