From: "Martin v. Loewis" <martin@v.loewis.de> > "Thomas Heller" <thomas.heller@ion-tof.com> writes: > > > Can't you at least partly combine the advantages of 1 and 2 by using > > thread local storage for the global variable? I have no idea if there > > is a portable way to do this... > > That would work, but, as you already guess: there is no portable way > to do this. If you can accept platform-specific code, this is a good > idea. > [in another message] > The pthreads equivalent of Windows TLS is > pthread_getspecific/setspecific, so you could cover pthreads and Win32. Normally I don't care too much about portable code, but in this case (storing and retriving the current threadstate between calls to C code and callbacks from C-code into Python code) the most benefits could only be gained if the Python core and hopefully also extension developers cooperated and used this method. Maybe the Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS macros could be changed to store the threadstate in a global TLS area for Windows and pthreads platforms? Thomas
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