There are a great many hash functions that would work for those constraints and it really depends on the likely distribution of characters as to which is the best.
I assume your 6410
figure is meant to be the number of possibilities for variable names but it's slightly wrong - it should be 52x629
to to the limitation that the first character cannot be numeric but, in any case, that doesn't allow for variables shorter than ten characters so it's approximate only. In reality, it would be something like 52 + 52x62 + 52x622 + 52x622 + ... + 52x629
.
It's also pretty much irrelevant to the hash function itself.
Probably the simplest hash function you can choose is to run through the variable name extracting each "value" (0 through 61 for the 26 uppercase, 26 lowercase and 10 numeric) and simply calculate a value between 0 and 999 based on that:
def hashIt (varname):
chars =
"0123456789" +
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
abcdefghijklmnopqrstuvwxyz"
hashVal = 0
for each char in varname:
hashVal = (hashVal * len(chars) + chars.findIndexOf(char)) % 1000
return hashVal
Again, that doesn't take into account likely distribution of letters but, since you've provided no information on that, there's mot much we can do.