cachier
cachier copied to clipboard
Per object type hashing handlers
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."
Off the top of my head:
- Checking types is less trivial in Python than in other programming languages, or at least slower, I think.
- 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
cachierknow with which object type this handler is associated). I'm imagining adict; probably there's a sensible way to make this sufficiently convenient.
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.