[Tutor] Intermediate/advanced concepts

Kent Johnson kent37 at tds.net
Sat Nov 8 04:58:35 CET 2008


On Fri, Nov 7, 2008 at 6:16 PM, Alan Gauld <alan.gauld at btinternet.com> wrote:

> True, but its pretty rare that timing issues are a reason for me to choose a
> data structure

I would guess you commonly choose a dict or set over a list when you
need fast tests for membership. Failure to choose dict when
appropriate is certainly a common cause of performance problems.

> But the geneal point is a good specific example (and I was struggling to
> think of one!) where you might choose a non standard list over the vanilla
> version. The array module is another case where performance is improved over
> the standard lists.

The standard lib also includes collections.deque (O(1) insertion and
deletion at both ends) and heapq (binary priority queue). Third party
implementations of b-tree, avltree and trie are available which have
better performance than list and dict for some usage.

Kent


More information about the Tutor mailing list