Python and GIL

Chris Angelico rosuav at gmail.com
Thu May 30 14:30:49 EDT 2013


On Fri, May 31, 2013 at 4:14 AM, Ana Marija Sokovic
<sokovic.anamarija at gmail.com> wrote:
> Hi,
>
> Can somebody explain to me how would you proceed in releasing the GIL and
> whether you think it will have consequences?

You release the GIL in C-level code when you don't need to work with
Python objects for a while. Simple example is when you need to wait
for something - for instance, if you attempt to read from a pipe, you
can release the GIL before reading, then reacquire it afterward. The
consequence is that you can't do anything with Python objects till you
reacquire it. It's like any other resource-guarding mutex lock.

ChrisA



More information about the Python-list mailing list