This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients barry, eli.bendersky, eric.smith, ethan.furman, mrabarnett, pitrou, r.david.murray, rhettinger, serhiy.storchaka, theller, tim.peters, vstinner
Date 2013-09-09.22:22:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1378765349.66.0.143534327782.issue18986@psf.upfronthosting.co.za>
In-reply-to
Content
> 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.
History
Date User Action Args
2013-09-09 22:22:29serhiy.storchakasetrecipients: + serhiy.storchaka, tim.peters, barry, theller, rhettinger, pitrou, vstinner, eric.smith, mrabarnett, r.david.murray, eli.bendersky, ethan.furman
2013-09-09 22:22:29serhiy.storchakasetmessageid: <1378765349.66.0.143534327782.issue18986@psf.upfronthosting.co.za>
2013-09-09 22:22:29serhiy.storchakalinkissue18986 messages
2013-09-09 22:22:29serhiy.storchakacreate