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 <rep...@bugs.python.org>
<http://bugs.python.org/issue19224>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to