8000 Improve and amend `hashlib.__doc__` · Issue #136565 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
Improve and amend hashlib.__doc__ #136565
Closed
Closed
@picnixz

Description

@picnixz

Feature or enhancement

Proposal:

There are a few typos in hashlib.__doc__ and I would like the usage example to be consistent (one example is MD5 while the other, introduced by "more condensed:" is using SHA-224). We also say:

Choose your hash function wisely. Some have known collision weaknesses. sha384 and sha512 will be slow on 32 bit platforms.

But SHA-384 and SHA-512 won't be necessary slow on 32-bit platforms. What we can say however is that, depending on how it's implemented, they are usually faster on 64-bit platforms compared to SHA-224 and SHA-256. The reason is that internal computations use 64-bit words, whereas the SHA-224 and SHA-256 use 32-bit words, even on 64-bit platforms.

As I haven't exactly reviewed the performance and the OpenSSL/HACL* implementations of SHA-384 and SHA-512, I suggest we remove this notice as it could be misleading. Saying that they will be faster than SHA-224 and SHA-256 should also be avoided as I can't test this. So, I would say:

Choose your hash function wisely. Some have known collision weaknesses, while others may be slower depending on the CPU architecture.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Metadata

Metadata

Assignees

Labels

stdlibPython modules in the Lib dirtype-featureA feature request or enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0