[Python-ideas] Dict view on list of two-tuples

Ian Bicking ianb at colorstudy.com
Tue Apr 5 02:21:25 CEST 2011


On Mon, Apr 4, 2011 at 7:14 PM, Steven D'Aprano <steve at pearwood.info> wrote:

> Ian Bicking wrote:
>
>> On Mon, Apr 4, 2011 at 5:56 PM, Steven D'Aprano <steve at pearwood.info>
>> wrote:
>>
>>  Data structures with an internal representation like {'a':
>>>
>>>> ['1', '3'], 'b': ['2']} are not sufficient.
>>>>
>>>>  How do you know? The ordered dict implementation in the standard
>>> library
>>> has an internal dict representation (or at least it did, when it was on
>>> ActiveState). Why do you care whether the implementation uses a dict
>>> internally, so long as the interface matches the specified (and as yet
>>> not
>>> entirely decided) API?
>>>
>>
>>
>> Well, I can say at least that it would not be sufficient for me to use it
>> in
>> WebOb -- I wouldn't consider it acceptable to lose the full ordering of
>> all
>> keys, as would happen if you used this structure.  It might be suitable
>> for
>> some other use, but I have no such use in mind at the moment, so diverging
>> from this it would no longer be the idea that led me to start the thread
>> ;)
>>
>
> You have missed my point. What makes you think that using a dict as part of
> the *internal implementation* would mean that you lose the full ordering of
> keys? ordereddict has full ordering of keys, and it uses a dict as the
> internal implementation.
>

I was referring to the representation as a shorthand for what I considered a
common but poor implementation of the concept -- *that specific* internal
representation has specific results which I consider unacceptable (that is,
it keeps the relative ordering of the values of one key, but doesn't keep
the ordering between keys).  Another representation that uses a dict could
be fine, but I didn't offer a generic representation, I offered a specific
one.

  Ian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110404/1cba8563/attachment.html>


More information about the Python-ideas mailing list