nexus

View the Project on GitHub robfatland/nexus

nexus, index source, nexus main

Python

In this directory

Topics covered here

A wish list… topics I’d like to understand

hashing

This code:

print('this string', hash('this string'))
print(10, hash(10))
n = 10
print(n, hash(n))
n = 10.0
print(n, hash(n))
n = 10.1
print(n, hash(n))

produces

this string 8534039767811493564
10 10
10 10
10.0 10
10.1 230584300921368586

So 10^20 is roughly the dynamic range apparent in Python hashing. This is the case as well for larger objects such as a string of 600 characters. There are say (10^2)^20 possible strings of length 20… so surely it is possible to have hash collisions. These do happen (and the birthday paradox is relevant). There are two ideas to note in consequence: