4 ms·
Can't you also defer work to c extensions in threads?
by ses1984 7y ago
Can't you also defer work to c extensions in threads?
- nine_k 7y agoSome extensions do release GIL while doing its own parallel processing, so, to a degree, yes.
- celticmusic 7y agoI don't know the specifics of Python's C interfaces, but I know Ruby by default will cover all 3rd party extensions in the GIL for safety and you can release it upon entry into the extension using the C api. But doing so can be very dangerous if you're calling back into the Ruby core as you could inadvertently cause problems that the GIL was meant to protect you from. I imagine Python works roughly the same.
- paulddraper 7y agoYes. Numpy releases the GIL for its array operations. Parallelism is possible, but only for computations in native code. FWIW Node.js is essentially the same situation.
- nine_k 7y agoNode got background workers recently. Otherwise yes, Node or Ruby play by the same global lock rules.
- paulddraper 7y agoSame in Python, except multiprocessing has actually been around for longer. Launching multiple processes without mutable shared memory is always an option.