Home  >  Article  >  Backend Development  >  Detailed introduction to Python's built-in hash function

Detailed introduction to Python's built-in hash function

高洛峰
高洛峰Original
2017-03-21 10:52:262570browse

English document:

##hash<a href="http://www.php.cn/wiki/739.html" target="_blank"></a>(object)Return the hash value of the object (if it has one). Hash values ​​are integers. They are used to quickly compare dictionary keys during a dictionary lookup. Numeric values ​​that compare equal have the same hash value (even if they are of different types, as is the case for 1 and 1.0) .

Instructions:  

1. Return the hash value of

object, using integer express. Hash values ​​can be used to quickly compare key values ​​during dictionary lookups.

>>> hash('good good study')
1032709256
 2. For equal values, even if the types are inconsistent, the calculated hash value is the same.

>>> 1.0 == 1
True
>>> hash(1.0)
>>> hash(1)
>>> hash(1.0000)

The above is the detailed content of Detailed introduction to Python's built-in hash function. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn