> > Should there be Py_BEGIN_AUTO_THREAD_STATE_ENSURE and > > Py_END_AUTO_THREAD_STATE_ENSURE macros (analogous to > > Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS) as well, > > then? > > I'm not sure we can really get away with this. For C code, a common pattern > will need to be: > > PyAutoThreadState_State state; > .. some code > state = PyAutoThreadState_Ensure(); > ... more code > PyAutoThreadState_Ensure(state); > } > > We actually need all 3 blocks. Unlike Py_BEGIN_ALLOW_THREADS, we can't > create a new scope to declare a local variable in, as that variable is > needed by the outer most scope. > > I guess: > Py_AUTO_THREAD_STATE_DECLARE > Py_AUTO_THREAD_STATE_ENSURE > Py_AUTO_THREAD_STATE_RELEASE > > would work. The macros don't look more attractive than the explicit code. > OTOH, in the code I am patching there already exists "#ifdef > __cplusplus" - I am so tempted to add a tiny little extra block > define a helper C++ class in the Python sources for managing this. > However, if I do that I fear the Spanish Inquisition will look like > a stroll in the park <wink> Cardinal Biggles, get the soft cushions! Actually, relying on C++ would be bad, since this might be useful outside Windows as well. --Guido van Rossum (home page: http://www.python.org/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4