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
Make digest_size a class variable #70887
Comments
It would be nicer if this worked: >>> hashlib.md5.digest_size
64 |
+cc Christian Heimes: do the upcoming standard hash functions amenable to a constant class attribute digest_size? Are any of the expected future hashes variable length from a single class / constructor function? |
Not all hash functions have a fixed digest size, e.g. blake2 is a variable length hash algorithm. https://pythonhosted.org/pyblake2/examples.html#using-different-digest-sizes How about a new class attribute default_digest_size? |
I agree that adding a .default_digest_size attribute to the constructors in the hashlib module would be good... the challenge is in actually doing it. Today they are not classes, they are built-in functions that come from one of two possible extension modules. Adding properties to a built-in function is a challenge (I don't think that is even possible in the C API, PyMethodDef doesn't support that). We could hack around it, wrap them in classes, etc. But they have never been classes and there is little good reason for them to be a type. |
I'm rejecting this one as low value / infeasible. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: