[Python-ideas] Identity dicts and sets

Bruce Leban bruce at leapyear.org
Thu Jan 3 19:55:02 CET 2013


On Thu, Jan 3, 2013 at 3:50 AM, Serhiy Storchaka <storchaka at gmail.com>wrote:

> On 02.01.13 23:33, Bruce Leban wrote:
>
>> I agree collections is the place to put it but that would give us three
>> specialized subclasses of dictionary which cannot be combined. That is,
>> I can have a dictionary with a default, one that is ordered or one that
>> uses a key function but not any combination of those. It would seem
>> better to have something like Haoyi Li suggested:
>>
>> collections.Dictionary(**default=None, ordered=False, key=None) --> a
>> dict
>> subclass
>>
>
> I doubt if such combinations have a sense. At least not all features can
> be combined.


I agree that all feature combinations may not make sense. I think a default
ordered dict would be useful and if other dict variations are created,
combinations of them may be useful too. I don't know if identity dicts are
useful enough to add, but I think that if another dict variation is added,
using a factory should be considered.

I have specifically wanted a sorted default dict in the past. (A sorted
dict is like an ordered dict but the order is sorted by key not by
insertion order. It is simulated by iterating over sorted(dict.keys()). I
doubt that sorted dict is common enough to be worth adding, but if it were
it would be unfortunate to not have a default variation of it.)

--- Bruce
Check this out: http://kck.st/YeqGxQ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130103/93092406/attachment.html>


More information about the Python-ideas mailing list