Message382172
Yep, Mark Shannon's solution of contextual hashing is what I was trying (without success) when my last computer died (without backing up work offsite, oops) and I gave up on this for a while. And Batuhan Taskaya's note about compiler dictionaries for the constants being a problem is where I got stuck.
Switching to lists might work (I never pursued this far enough to profile it to see what the performance impact was; presumably for small functions it would be near zero, while larger functions might compile more slowly).
The other approach I considered (and was partway through implementing when the computer died) was to use a dict subclass specifically for the constants dictionaries; inherit almost everything from regular dicts, but with built-in knowledge of slices so it could perform hashing on their behalf (I believe you could use the KnownHash APIs to keep custom code minimal; you just check for slices, fake their hash if you got one and call the KnownHash API, otherwise, defer to dict normally). Just an extension of the code.__hash__ trick, adding a couple more small hacks into small parts of Python so they treat slices as hashable only in that context without allowing non-intuitive behaviors in normal dict usage. |
|
Date |
User |
Action |
Args |
2020-11-30 18:46:42 | josh.r | set | recipients:
+ josh.r, rhettinger, terry.reedy, mark.dickinson, christian.heimes, Mark.Shannon, serhiy.storchaka, pablogsal, BTaskaya |
2020-11-30 18:46:42 | josh.r | set | messageid: <1606762002.46.0.647837428449.issue42454@roundup.psfhosted.org> |
2020-11-30 18:46:42 | josh.r | link | issue42454 messages |
2020-11-30 18:46:42 | josh.r | create | |
|