[Python-3000] Kill GIL?
"Martin v. Löwis"
martin at v.loewis.de
Mon Sep 18 08:44:41 CEST 2006
Andre Meyer schrieb:
> While I understand the difficulties in removing the GIL and the
> potential negative effect on single-threaded applications I would very
> much encourage discussion to seriously consider removing the GIL (maybe
> optionally) in Py3k. If not, what alternatives would you suggest?
Encouraging "very much" is probably not good enough to make anything
happen. Actual code contributions may, as may offering a bounty
(although it probably depends on the size of the bounty whether anybody
wants to collect it).
The alternatives are very straight-forward:
1. use Python the same way as you did for Python 2.x. I.e. create
many threads, and have only one of them run. Use the other processors
for something else, or don't use them at all.
2. use Python the same way as many other people do. Don't use threads,
instead use multiple processors, and some sort of IPC.
3. don't use Python, at least not for the activities that need to
run on multiple processors.
If you want to fully use your multiple processors, depending on the
application, I'd typically go with option 2 or 3. Option 2 if the code
to parallelize is written in Python, option 3 if it is written in C
(yes, you can use multiple truly concurrent threads in Python: just
release the GIL on the C level; you can't make any calls into Python
until you reacquire the GIL).
More information about the Python-3000