←back to thread

258 points rbanffy | 4 comments | | HN request time: 0.848s | source
Show context
AlexanderDhoore ◴[] No.44003888[source]
Am I the only one who sort of fears the day when Python loses the GIL? I don't think Python developers know what they’re asking for. I don't really trust complex multithreaded code in any language. Python, with its dynamic nature, I trust least of all.
replies(19): >>44003924 #>>44003936 #>>44003940 #>>44003943 #>>44003945 #>>44003958 #>>44003971 #>>44004203 #>>44004251 #>>44004431 #>>44004501 #>>44005012 #>>44005100 #>>44005259 #>>44005773 #>>44006165 #>>44007388 #>>44011009 #>>44011917 #
txdv ◴[] No.44003940[source]
how does the the language being dynamic negatively affect the complexity of multithreading?
replies(4): >>44003967 #>>44005360 #>>44005981 #>>44006794 #
nottorp ◴[] No.44003967[source]
Is there so much legacy python multithreaded code anyway?

Considering everyone knew about the GIL, I'm thinking most people just wouldn't bother.

replies(1): >>44004034 #
1. toxik ◴[] No.44004034[source]
There is, and what's worse, it assumes a global lock will keep things synchronized.
replies(1): >>44004133 #
2. rowanG077 ◴[] No.44004133[source]
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.
replies(1): >>44004265 #
3. immibis ◴[] No.44004265[source]
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.
replies(1): >>44004683 #
4. kfrane ◴[] No.44004683{3}[source]
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.