Closed hackaugusto closed 4 years ago
Please open an issue on the Python bug tracker, or bring it up on the python-ideas mailing list. My first impression is that this is too specialized to be added to dataclasses. I'd suggest writing your own __hash__
function.
I'm going to close this, since this tracker is just for backport issues, not new features.
I was modeling a toy blockchain using dataclasses and I had something roughly like this:
The problem is that the cost of
hash(block)
increases linearly with the length of the parent chain. What do you think about caching the result of thehash
function? It will not fix the problem in general (this is a toy example anyways), but it will alleviate the problem for a toy script like the one I was writing.Let me know if I should open another issue in the python issue tracker, and if the PR makes sense.Thanks!