[Python-ideas] Preserving **kwargs order

Chris Angelico rosuav at gmail.com
Fri Apr 4 00:24:00 CEST 2014


On Fri, Apr 4, 2014 at 6:14 AM,  <random832 at fastmail.us> wrote:
> Iterating in insertion order would make the iteration completely
> independent of the hashing algorithm. The hashing algorithm determines
> what buckets each item goes in, but you don't _have_ to iterate in
> bucket order, depending on your data structure. C#, for example, stores
> items in an array [which are populated from a freelist of array slots
> that don't have items in them, or sequentially at the end of the array
> if there are no slots in the freelist] and the buckets as linked lists
> within the array.

However that's done, it implies additional storage beyond the
straight-forward mapping, right? Python's dict implementation is
*highly* optimized (which is necessary, given how much of Python is
built on dicts), and any proposal that basically says "Every dict
needs to keep track of insertion order, for the sake of the handful of
cases where you actually care" is likely to have the aerodynamic
qualities of a rock.

ChrisA


More information about the Python-ideas mailing list