[pycrypto] Release the GIL

don at amberfisharts.com don at amberfisharts.com
Tue Sep 29 17:13:52 CST 2009


Hi,

I noticed that generating RSA keys takes quite some time (~10s on my Netbook) so I
wanted to load it of into a separate thread. This didn't help at all.

After investigating I found that releasing the GIL in isPrime() in _fastmath.c using the Py_BEGIN/END_ALLOW_THREADS macros solved my problem.

So I'm wondering is there a reason NOT to release the GIL that I am not aware of?
If not could this be included in the upcoming 2.1 release?

Maybe there are some other long running C-level calls where releasing the GIL would make sense but so far I only had problems with isPrime (mpz_probab_prime_p).


sincerely yours
//Lorenz




More information about the pycrypto mailing list