Python 3.2 - GIL - good/bad?

前端 未结 3 462
傲寒
傲寒 2021-02-01 19:20

Python 3.2 ALPHA is out.

From the Change Log, it appears the GIL has been entirely rewritten.

A few questions:

  1. Is having a GIL good or bad? (and wh
3条回答
  •  情歌与酒
    2021-02-01 20:02

    Is the new GIL better? If so, how?

    Well, it at least replaces op-count switching to proper time-count. This does not increase overall performance (and could even hurt it due to more often switching), but this makes threads more responsive and eliminates cases when ALL threads get locked if one of them uses computation-heavy single op-code (like call to external function which does not release GIL).

    why does CPython not just clone the interpreter like Perl does in an attempt to remove the need for the GIL?

    GIL is complex issue, it should not be viewed as Ultimate Evil. It brings us thread-safety.

    As for perl, perl is a) dead, b) too old. Guys at Google are working on bringing LLVM goodies to CPython, which, among others, will improve GIL behavior (no complete GIL removal yet, tho): http://code.google.com/p/unladen-swallow/

提交回复
热议问题