Message197410
> I'm curious to know how you'll integrate it in dictobject.c without slowing down normal dict objects, and without making them bigger.
It of course will make a size of source file bigger, but shouldn't affect a size or performance of normal dicts. A dict object contains dk_lookup. Constructor for keyed dict (subclass of ) should initialize it with specialized function which calls the "key" function and recalculate a hash (yes, with this simple approach a hash will be calculated twice, for original and for transformed keys). Hmm, actually it can be even simpler than for IdentityDict (for which not calculating a hash was important). Also some other methods which relies on dict implementation details (e.g. making a copy of dict) should be modified.
The most cumbersome part is the tests. Unfortunately I lost my tests for IdentityDict (used hg diff without --git). It will be good if your provide complete test suite. |
|
Date |
User |
Action |
Args |
2013-09-09 22:22:29 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, tim.peters, barry, theller, rhettinger, pitrou, vstinner, eric.smith, mrabarnett, r.david.murray, eli.bendersky, ethan.furman |
2013-09-09 22:22:29 | serhiy.storchaka | set | messageid: <1378765349.66.0.143534327782.issue18986@psf.upfronthosting.co.za> |
2013-09-09 22:22:29 | serhiy.storchaka | link | issue18986 messages |
2013-09-09 22:22:29 | serhiy.storchaka | create | |
|