On Fri, Sep 12, 2008 at 10:33 AM, Guido van Rossum <[EMAIL PROTECTED]> wrote: > On Fri, Sep 12, 2008 at 10:13 AM, <[EMAIL PROTECTED]> wrote: >> >> >> select key from dict order by key >> >> select value from dict order by key >> >> Guido> What's the purpose of the "order by key" clauses here? Doesn't >> Guido> that force the return order? Perhaps you meant to leave those >> Guido> out? >> >> It's simply to guarantee that the order of the elements of values() is the >> same as the order of the elements of keys(). Again, I was thinking that >> this property: zip(d.keys(), d.values()) == d.items() was a desirable >> property of mappings, not just of the CPython dict implementation. > > But in SQL this would force alphabetical ordering so of course it > would both return them in corresponding order. Maybe we should just > drop this, it seems hardly relevant.
If the desire is to behave like a bsddb.btree instance, alphabetical is ok. Replacing the 'order by key' with 'order by rowid' is reasonably sane, if alphabetical is explicitly undesired. Really there are 3 options: alphabetical ordering, rowid ordering, no guaranteed ordering (which seems to be on-disk or rowid ordering, my brief tests tell me nothing). >> So is there a definition of what it means to be a mapping? Maybe this page >> in the C API doc? >> >> http://docs.python.org/api/mapping.html >> >> From that I infer that a mapping must offer these methods: keys, values, >> items, __len__, __contains__, __getitem__, __setitem__ and __delitem__. No >> guarantee about the ordering of keys, values and items is made. Can we >> settle on something like this and spell it out explicitly somewhere in the >> 3.0 docs? > > That's a C API definition that hasn't been updated. If anything > documents the concept of a mapping it would be the Mapping ABC in the > collections module. According to PEP 3119 on the mapping ABC: "i.e. iterating over the items, keys and values should return results in the same order." So... key ordered, or rowid ordered? - Josiah _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com