Fix #5339: cache dtype.__hash__.