On this page
hash
Prev: hasattr | Up: __builtins__ | Next: help
Rel: callable, delattr, dir, getattr, hasattr
Ref: docs.python.org — hash
Tags: #public #python3 #builtins
Import & Availability
# Built-in (available globally without import)
from builtins import hash
Overview & Signature
hash(obj, /)
Return the integer hash value for the given object.
Usage
assert hash((1, "a")) == hash((1, "a"))
Gotchas
- Salted randomly per process for
str/bytes: Never storehash()output in databases or compare it across runs—usehashlib.sha256()instead. - Equal objects must have equal hashes:
hash(1) == hash(1.0) == hash(True).
REPL Inspect
help(hash)
Linked from
Related notes
- tuts/python3/__builtins__/__builtins__ Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/callable Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/delattr Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/dir Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/getattr Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/hasattr Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/help Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__ links to this page; shared tags: #builtins
- tuts/c/builtins shared tags: #builtins
- tuts/c/builtins/__FILE__ shared tags: #builtins