-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvement: Less GIL locking #197
Comments
-- @zwimer could you please elaborate on this? Particularly why should we assume that |
Oh! My mistake, I misread the documentation in pybind11 to say the GIL is not held by default: https://pybind11.readthedocs.io/en/stable/advanced/misc.html?highlight=GIL#global-interpreter-lock-gil In that case (perhaps this is better for a different issue?), would it be reasonable to feature request a 'do not hold the GIL' option in binder? Some libraries are designed to be thread-safe and do not need the GIL / actively do not want the GIL held. This could be a global option or a per-class / per-function / per-namespace option. |
Interesting idea @zwimer ! I think this should be possible to do on the class level or/and namespace level. Let me think about how is it best to handle this. |
Binder currently seems to grab the GIL where not necessary. Here is an example:
Notice that that
return Base::eliminatable();
is influenced bypybind11::gil_scoped_acquire gil;
; but ifAnnotation::Base().eliminatable
is itself threadsafe this function should not need to be protected by the GIL. In that case, this can be modified in one of 2 ways:eliminatable()
the GIL need not be acquired.The text was updated successfully, but these errors were encountered: