-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-135239: simpler use of mutex in hashlib & co #135267
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that PyMutex_Lock
will release the GIL/detach the thread state anyway. You want _PyMutex_LockFlags(m, _Py_LOCK_DONT_DETACH)
if you're worried about GIL overhead.
…135239 # Conflicts: # Modules/_hashopenssl.c # Modules/blake2module.c
bb237c2
to
db57278
Compare
That sounds fine to me, but make sure that the locking is done in a consistent order. Note that acquiring the lock will release the GIL, unless you explicitly tell it not to with |
…135239 # Conflicts: # Modules/hmacmodule.c
…135239 # Conflicts: # Modules/hmacmodule.c
…135239 # Conflicts: # Modules/md5module.c
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
I'll check performance tomorrow. The (full) tests are much slower now but that's because I'm testing all known hash functions, whereas before, we only tested SHA-1. |
I've taken the liberty of normalizing code style. I'll do the same in other modules, (SHA and BLAKE2). That way, I'll never need to touch cosmetics again in crypto-modules. Well, if it's too much I can drop the last commit.