[Python-Dev] Dict constructor

Tim Peters tim@zope.com
Wed, 26 Jun 2002 15:18:52 -0400

[Raymond Hettinger]
> Second wild idea of the day:
> The dict constructor currently accepts sequences where each element has
> length 2, interpreted as a key-value pair.
> Let's have it also accept sequences with elements of length 1,
> interpreted as a key:None pair.

-1 because of ambiguity.  Is this trying to build a set with the single
element (42, 666), or a mapping of 42 to 666?

    dict([(42, 666)]}

The same dilemma but perhaps subtler:

    dict(["ab", "cd", "ef"])

> The benefit is that it provides a way to rapidly construct sets:

I've got nothing against sets, but don't think we should push raw dicts any
closer to supporting them directly than they already are.  Better for
someone to take over Greg Wilson's PEP to add a new set module; I also note
that Zope/ZODB's BTree package supports BTree-based sets directly as a
distinct (from BTree-based mappings) datatype.