[Python-Dev] Proposal: add odict to collections (original) (raw)

Stephen Hansen apt.shansen at gmail.com
Mon Jun 16 06:16:59 CEST 2008


But my point is that we we need to focus on finding real use cases and exploring how best to solve them. Otherwise we might as well throw in my OrderedSet[1] as-is, despite that it's got no comments and no ratings. Even I don't seem to use it.

I'm mostly lurking on these threads, so as to be semi-prepared when new versions come out.. in fifty years, since we just migrated from 2.3 to 2.4 on our product, so. :)

Anyways, we've had an OrderedDictionary sort of implementation in our library for eons. The product is commercial and a mix between a desktop application and a web one, with an application server and cross-platform availability... so there's a slightly bizarre and wide range of uses that we've found for putting ordered dictionaries to. If some various use-cases and our reasoning helps, here it is. If not, ignore :)

Basically, after looking at all of these, my impressions of an "ordered dictionary" for the various use cases we use are:

And not: ['there', 'hello']

An ordered dictionary that does not simply preserve initial insertion order strikes me as a sorted dictionary-- sorting on insertion time. I'd expect a sorted dictionary to shift itself around as appropriate. I'd not expect an ordered dictionary to change the order without some explicit action.

To me, "ordered dictionary" is in fact a preordered dictionary. The order is defined before the data in, and the dictionary's job is to just preserve it.

Anyways. No idea if that'll help the discussion, but a couple people kept talking about use cases :)

--Stephen P.S. Our implementation, incidentally, is essentially the same as one mentioned above though its subclassing from UserDict (historical reasons for now). We just track the keys in _keys, and if someone's setting something in the dictionary not in keys, we append. It seemed the most natural/obvious way to do it. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20080615/c6e89f7e/attachment-0001.htm>



More information about the Python-Dev mailing list