Utilities for working with data structures like lists, dicts and tuples.
Chop a sequence into chunks of the given size.
Flatten a list of lists (NOT recursive, only works for 2d lists).
Get a slice of a sequence with variable step. Specify start,stop,step.
Takes a list of (key,value) pairs and turns it into a dict.
Takes a list and turns it into a dict. Much slower than list2dict, but more versatile. This version can take lists with sublists of arbitrary length (including sclars).
Sort and compare two lists.
By default it does it in place, thus modifying the lists. Use inplace = 0 to avoid that (at the cost of temporary copy creation).
Return from an iterable, a list of all the unique elements in the input, but maintaining the order in which they first appear.
A naive solution to this problem which just makes a dictionary with the elements as keys fails to respect the stability condition, since dictionaries are unsorted by nature.
Note: All elements in the input must be valid dictionary keys for this routine to work, as it internally uses a dictionary for efficiency reasons.