cachier icon indicating copy to clipboard operation
cachier copied to clipboard

Per object type hashing handlers

Open shaypal5 opened this issue 1 year ago • 2 comments

A suggestion by @blakeNaccarato

"I think the hash function extension concept could be neatly extended by designating "handlers" for certain object types. Instead of overriding the entire hash method altogether, users could supply handlers which take an object and return a Hashable, which could be fed into a built-in pre-hasher stage that just applies all hash handlers. Sorry this is a different concept but I encountered it at the same time as the caching backend concept and wanted to address it. Would probably be a different Issue and feature effort altogether."

shaypal5 avatar Nov 27 '23 09:11 shaypal5

Off the top of my head:

  1. Checking types is less trivial in Python than in other programming languages, or at least slower, I think.
  2. What would the interface look like? It should be rather convenient and concise to provide 3 different handles, each is additionally provided with a type "spec" (letting cachier know with which object type this handler is associated). I'm imagining a dict; probably there's a sensible way to make this sufficiently convenient.

shaypal5 avatar Nov 27 '23 09:11 shaypal5

It looks like time has gotten away from me here, so I figured I'd chime in to say I'm still alive. I haven't gotten around to the implementation, though I do still intend to, and would like to put time into it this month. If any passers-by see this and are eager to work on this themselves, just @ me and I'll try to respond promptly.

blakeNaccarato avatar Jan 03 '24 22:01 blakeNaccarato