Issue 26700: Make digest_size a class variable (original) (raw)

Issue26700

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.

This issue has been migrated to GitHub: https://github.com/python/cpython/issues/70887

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:29 admin set github: 70887
2017-05-06 22:50:43 gregory.p.smith set status: open -> closedmessages: + assignee: gregory.p.smith -> resolution: rejectedstage: resolved
2016-09-09 21:05:03 gregory.p.smith set messages: +
2016-05-31 17:01:22 christian.heimes set messages: +
2016-05-31 16:52:44 gregory.p.smith set nosy: + christian.heimesmessages: +
2016-04-06 07:59:10 rhettinger create