#5 Python Data Types: Collections Module| DefaultDictionary | NamedTuple | Counter | Deque

By Jaydeep Karale on youtube.com

More about this content:

#python #datatypes #collections #namedtuple #deque #conunter #defaultdict This module implements specialized container datatypes providing alternatives to Python’s general purpose built-in containers, dict, list, set, and tuple. 1) Counter A Counter is a dict subclass for counting hashable objects. It is a collection where elements are stored as dictionary keys and their counts are stored as dictionary values. Counts are allowed to be any integer value including zero or negative counts. The Counter class is similar to bags or multisets in other languages. 2) DefaultDict Returns a new dictionary-like object. defaultdict is a subclass of the built-in dict class. It overrides one method and adds one writable instance variable. The remaining functionality is the same as for the dict class and is not documented here 3) Deque Returns a new deque object initialized left-to-right (using append()) with data from iterable. If iterable is not specified, the new deque is empty. Deques are a generalization of stacks and queues (the name is pronounced “deck” and is short for “double-ended queue”). Deques support thread-safe, memory efficient appends and pops from either side of the deque with approximately the same O(1) performance in either direction. 4) NamedTuple Returns a new tuple subclass named typename. The new subclass is used to create tuple-like objects that have fields accessible by attribute lookup as well as being indexable and iterable. Instances of the subclass also have a helpful docstring (with typename and field_names) and a helpful __repr__() method which lists the tuple contents in a name=value format VIDEO ON HASH VALUE https://www.youtube.com/watch?v=MrAcI4-kzss Outro Courtesy :- https://www.youtube.com/watch?v=ntorJi-36ds Buy Me A Coffee :- https://ko-fi.com/jaydjournal Follow Me On Twitter :- https://twitter.com/JayDeepKarale Follow Me On Instagram :- https://www.instagram.com/jonesoncorners/


Join related learning paths