DEV Community

Discussion on: GIL in Python

Collapse
 
ksaaskil profile image
Info Comment hidden by post author - thread only visible in this permalink
Kimmo Sääskilahti • Edited

Thanks for the article!

The performance of the single-threaded process and the multi-threaded process will be the same in python and this is because of GIL in python.

It's maybe worth stressing here that multi-threading can make execution a lot faster. It requires that threads release the GIL when e.g. waiting on I/O. Well-written libraries like NumPy release the GIL whenever possible, allowing multiple computations to proceed in parallel.

Threading runs on a single processor and therefore only runs one at a time.

Single Python process can use multiple cores at the same time in parallel. Try starting e.g. two threads each making a numerical computation with NumPy and you may see the process CPU usage going up to 200 %.

Collapse
 
aniketsingh98571 profile image
Aniket Singh

yes, it can be taken into consideration although writing on such advanced topics was quite challenging for me, thanks for your feedback noted it.

Some comments have been hidden by the post's author - find out more