I have a function that returns an energy associated with a vector in 3D space, F(i,j,k).
F() is a slow function, so I have a dictionary that checks if F() has been called for a specific i,j,k, and if it has then I just take that value from the dictionary.
I'm currently doing this as:
key = "_".join( [ str(i), str(j), str(k) ])
if key not in dic:
dic[key] = F(i,j,k)
Energy = dic[key]
Is there a better way to create a key than by joining the vectors like this?
map, tokey = "_".join(map(str, (i, j, k)))