STINNER Victor <victor.stin...@haypocalc.com> added the comment: > Releasing the GIL is somewhat expensive and should be avoided > if possible.
Another possible solution is to create a lockless object by default, and create a lock if the data size is bigger than N (eg. 8 KB). When the lock is created, update will always use the lock (and so the GIL). In general, you have two classes of hashlib usages: - hash a big files by chunk of k KB (eg. 256 KB) - hash a very small string (eg. 8 bytes) When you have a small string, you don't need to release the GIL nor to use locks. Whereas for a file, you can always release the GIL (and so you need a lock to protect the context). _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue4751> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com