default dictionary named tuple ordered dictionary modules the collections package provides the collections defaultdict dictionary and the collections namedtuple collection data types that we have previously discussed in additionthis package provides the collections userlist and collections userdict typesalthough subclassing the built-in list and dict types is probably more common than using these types another type is collections dequewhich is similar to listbut whereas list is very fast for adding and removing items at the enda collections deque is very fast for adding and removing items both at the beginning and at the end python introduced the collections ordereddict and the collections counter classes ordereddicts have the same api as normal dictsalthough when iterated the items are always returned in insertion order ( from first to last inserted)and the popitem(method always returns the most recently added ( lastitem the counter class is dict subclass used to provide fast and easy way of keeping various counts given an iterable or mapping (such as dictionary) counter instance canfor examplereturn list of the unique elements or list of the most common elements as (elementcount -tuples python' non-numeric abstract base classes (classes that can be inherited from but that cannot be used directlyare also in the collections package they are discussed in the array module provides the array array sequence type that can store numbers or characters in very space-efficient way it has similar behavior to lists except that the type of object it can store is fixed when it is createdso unlike lists it cannot store objects of different types the third-party numpy package mentioned earlier also provides efficient arrays the weakref module provides functionality for creating weak references--these behave like normal object referencesexcept that if the only reference to an object is weak referencethe object can still be scheduled for garbage collection this prevents objects from being kept in memory simply because we have reference to them naturallywe can check whether the object weak reference refers to still existsand can access the object if it does examplethe heapq module the heapq module provides functions for converting list into heap and for adding and removing items from the heap while preserving the heap property heap is binary tree that respects the heap propertywhich is that the first item (at index position is always the smallest item each of heap' subtrees is also heapso they too respect the heap property here is how heap could be created from scratchstrictly speakingthe heapq module provides min heapheaps where the first item is always the largest are max heaps