On Sun, Jul 1, 2012 at 11:36 PM, Chris Smith <[email protected]> wrote:
>>> Are you aware that there is now an ordered dictionary in python? It
>>> was backported to 2.7.3, I believe.
>>
>> This looks fine, but do you some data as to the speed?  [0] says that
>> it keeps the items in the order in which they were inserted.  That
>> smells of sequential storage and thus doesn't sound terribly cool
>> performance-wise, when random-access is needed.
>>
>
> Some details at http://tinyurl.com/8y4h9ad

Awesome, thank you!

This looks a lot like the implementation that has recently been
discussed in this thread: a regular Python dict (i.e., hash table)
accompanied by a list to know the order of the items.

By the way, for versions of Python younger than 2.7, there is [0].

There is a subtle point about ordered dicts vs. dicts, however.  There
are algorithms which do depend on order, and those which don't.  It
often happens so that at implementation a dependency on the order
slips by.  I think this should be pointed out by the corresponding
test failures.  On the other hand, for algorithms which inherently
need order, ordered dicts should be fine.

Sergiu

[0] http://pypi.python.org/pypi/ordereddict

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to