I'm pretty new to Python numpy. I attempted to use the numpy array as the key in the dictionary in one of my functions and then was told by the Python interpreter that the numpy array is not hashable. I've just found out that one way to work this issue around is to use repr() function to convert a numpy array to a string but it seems very expensive. Is there any better way to achieve the same effect?
Update: I could create a new class to contain the numpy array, which seems to be the right way to achieve what I want. Just wondering if there is any better method.
update 2: Using a class to contain data in the array and then override __hash__ function is acceptable, however, I'd prefer the solution provided by @hpaulj. Converting the array/list to a tuple fits my need in a better way as it does not require an additional class.
hashwhich could be used as a key for dictionary.tuple(A.tolist()). For a 1d array this conversion is straight forward.