4 ms·
Is the following possible? - library author marks their library "no-GIL" after making sure it's thread-safe without GIL - if the interpreter sees this metainf
by kgeist 3y ago
Is the following possible?
- library author marks their library "no-GIL" after making sure it's thread-safe without GIL
- if the interpreter sees this metainformation, it temporarily disables GIL for the current OS thread while running the library's code
- result: old versions of Python can still run no-GIL libraries under GIL, while new versions of Python allow to gradually remove GIL
Or it's not how CPython works?
- BGINBarbarian 3y agoAfaik, nogil will be a compile flag, which means that when there are two builds, you separately compile Gil and nogil builds. They will be two separate programs/binaries/packages. It could be possible for something like conda to install both binaries, then run your program with the one that matches the library flags, but python itself could not do this (afaik).