[Python-Dev] GIL required for _all_ Python calls?

"Martin v. Löwis" martin at v.loewis.de
Thu Jan 7 22:11:36 CET 2010


>> I don't think that's possible. The regex engine can also operate on
>> objects whose representation may move in memory when you don't hold
>> the GIL (e.g. buffers that get mutated).
> 
> Why is it a problem? If we get a buffer through the new buffer API, the object
> should ensure that the representation isn't moved away until the buffer is 
> released.

In 2.7, we currently get the buffer with bf_getreadbuffer. In 3.x, we have

    /* Release the buffer immediately --- possibly dangerous
       but doing something else would require some re-factoring
    */
    PyBuffer_Release(&view);


Even if we do use the new API, and correctly, it still might be
confusing if the contents of the buffer changes underneath.

Regards,
Martin



More information about the Python-Dev mailing list