Some Essential Built-in Tools for Working with Lists
While we are working with lists, sometimes we need to do some alternative tasks where the default DS is not enough. Then, either we have to write a function or we can use some built-in library to complete our task easily and fast.
array
The first one is array module which provides an array object like list but it can store data more compactly than list.
collections
collections is really an important module. Suppose we want to program a queue system. We can use a list. But it pops the last element which is used for stack Last In First Out(LIFO). On the other hand, queue is First In First Out(FIFO). We can write a function if we want but collection module provides a deque() object which is really helpful for queues and Bread First Search.
bisect
This one is really helpful if you want to play with a sorted list.
heapq
The heapq module provides functions for implementing heaps based on regular lists. It always enters the lowest value at position zero. This is useful when you want the smallest value without running a sort.
These modules are very handy. If you once become familiar with these, you would be able to save time by using these. For more reference please read The Python Documentation.