I just learned about the hash
method in Python, and I'm wondering: what is the relationship between an object and its hash value? For example:
>>>hash('a')
1567799509
What operations did python perform on the string 'a'
to arrive at 1567799509
? I know it's something related to hexadecimals, but what exactly is the formula used to get a hash value?
Also, I ran the following code:
a='a'
b="b"
c='c'
print (hash(a))
print(hash (b))
print(hash(c))
And I got this the first time I ran the code:
226468662
-199440459
-37886412
I got this the second time:
-121857168
-774818061
-915254158
I got this the third time:
1567799509
1439930198
1846375895
My questions is this: do hash values change? If so, why?