> On 17 Dec 2021, at 15:49, Chris Angelico <ros...@gmail.com> wrote: > > On Sat, Dec 18, 2021 at 1:44 AM Hao Hu <hao.hu...@gmail.com> wrote: >>> For that sort of thing, it may be more practical to use your own >>> hashing function, possibly a cryptographically secure one. The precise >>> hashing function used by Python isn't guaranteed, so if you need it to >>> be stable across different runs, and especially if you need to seed it >>> in a specific way, I'd recommend hashlib: >>> >>> https://docs.python.org/3/library/hashlib.html >> >> I’ve explored that option, however the siphash24 or fnv under the hood of >> *hash* seems to be more adapted for this type of use cases in terms of >> *performance*. >> Otherwise, would that be useful to add siphash24 or fnv in the hashlib as >> well? > > That's a more viable option, although maybe it wouldn't even matter. > How does hashlib.sha1() performance stack up, and what about a > handrolled simple string hashing function in Python? Is performance > actually going to be a problem with one of those? >
Great question. I agree that there could be other factors which slow things down much more than the hash function. I assume that this is a function that’ll be potentially called a lot of times, and the cumulated cost won’t be negligible. Maybe for the similar reason, some high performance networking tools adopt the same algorithm <https://www.wireguard.com/protocol/>. > ChrisA > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/LKXP3P7J7RBHC57SVS4VASDTVACIEM5S/ > Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/4P6EZRWWNFYS3PFRNZSW3NDLY2AGYSFK/ Code of Conduct: http://python.org/psf/codeofconduct/