This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Make digest_size a class variable
Type: enhancement Stage: resolved
Components: Extension Modules Versions: Python 3.6
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, gregory.p.smith, rhettinger
Priority: normal Keywords:

Created on 2016-04-06 07:59 by rhettinger, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (5)
msg262940 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2016-04-06 07:59
It would be nicer if this worked:

     >>> hashlib.md5.digest_size
     64
msg266761 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2016-05-31 16:52
+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?
msg266762 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2016-05-31 17:01
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?
msg275441 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2016-09-09 21:05
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.
msg293175 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2017-05-06 22:50
I'm rejecting this one as low value / infeasible.
History
Date User Action Args
2022-04-11 14:58:29adminsetgithub: 70887
2017-05-06 22:50:43gregory.p.smithsetstatus: open -> closed
messages: + msg293175

assignee: gregory.p.smith ->
resolution: rejected
stage: resolved
2016-09-09 21:05:03gregory.p.smithsetmessages: + msg275441
2016-05-31 17:01:22christian.heimessetmessages: + msg266762
2016-05-31 16:52:44gregory.p.smithsetnosy: + christian.heimes
messages: + msg266761
2016-04-06 07:59:10rhettingercreate