-
Notifications
You must be signed in to change notification settings - Fork 0
Efficiency
HowItWorks describes what's going on underneath the hood to get a good idea of the efficiency, if you understand the cost of the update() and digest() operations on a hash object.
I believe descending the tree takes work proportional to 1) the copying of hash objects, and 2) the work that occurs in the update() function when the buffer fills. I think the latter dominates, and although it's lumpy, amortized it's proportional to the lengths of the keys in __getitem__()
(subtree access) calls.
Then, calls to random methods call digest()
on every chunk of digest-size bits, and copy a hash object on all but the first chunk.
By comparison, the Python Mersenne Twister is always seeded with an SHA512 digest before generating its first bits, then does less work on later bits. (The seeding method also hashes any seeds other than ints, to 32 or 64 bits before giving to the SHA512.)