Serhiy Storchaka added the comment:

> 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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18986>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to