I'm trying to memoize a method foo(dti: DatetimeIndex)
using the @functools.lru_cache()
annotation. However, it complains with TypeError: unhashable type: 'DatetimeIndex'
.
Since DatetimeIndex
objects are immutable, there should be a good way to use them as a key for memoization, right?
Also, what would be wrong with DatetimeIndex
defining a hash method to simply return its id()
?