[issue19224] Make hash(None) consistent among processes

Tim Peters report at bugs.python.org
Sat Oct 12 06:51:34 CEST 2013


Tim Peters added the comment:

-0.

Since hash(None) is currently based on None's memory address, I appreciate that it's not reliable (e.g., use different releases of the same compiler to build Python, and hash(None) may be different between them).

The docs guarantee little about hash() results, so applications relying on cross-machine - or even same-machine cross-run - consistency are broken.

It's trivial code bloat to special-case None, but it leaves a world of other hash() behaviors as-is (essentially "undefined").  The `portable_hash()` function in the DPark source is a start at what needs to be done if an application wants reliable hashes.  But it's just a start (e.g., it's apparently relying on cross-platform consistency for `hash(integer)` and `hash(string)`, etc).

Since CPython will never promise to make _all_ of those consistent across platforms and releases, I'd rather not even start down that road.   Making the promise for `hash(None)` would be an attractive nuisance.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19224>
_______________________________________


More information about the Python-bugs-list mailing list