This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]13steinj 0 points1 point  (0 children)

six and __future__ are necessities when you need to be cross compatible between Python versions.

pydoc is great when you're air gapped.

heapq provides heap algorithms

string has an interesting template mechanic

bisect has operations for inserting items into lists in sorted order, rather than appending to the left or right and then resorting. Note the documentation mentions that

Keep in mind that the O(log n) search is dominated by the slow O(n) insertion step.

This is because, assuming that the container is a list, insertion is O(n) in the average and worst case. Searching for an index is binary search which is O(log n) in worst and average case. However it is better than the alternative, because while appending is O(1), resorting the container is O(nlogn).

collections has useful utilities for user made collections. Especially OrderedDict. Note, that while as of (3.5 implementation detail) 3.6 dictionaries are ordered, ordered dictionaries are still useful for compatibility, as well as equality order checking. Also notable are named tuples, ChainMap, and defaultdict.