8

Python's Collection Module: Introduction

 3 years ago
source link: https://dev.to/kathanvakharia/python-s-collection-module-introduction-4c4b
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Cover image for Python's Collection Module: Introduction

Python's Collection Module: Introduction

Jun 13

・1 min read

Introduction

This module implements specialized container datatypes providing alternatives to Python’s general purpose built-in containers, dict, list, set, and tuple.

What types does it offer?

Following are the most commonly used special container types of collections module,

Name Purpose Counter dict subclass for counting hashable objects OrderedDict dict subclass that remembers the order entries were added defaultdict dict subclass that calls a factory function to supply missing values deque list-like container with fast appends and pops on either end namedtuple factory function for creating tuple subclasses with named fields

And...

We can also implement a custom container type like OrderedCounter using the container types provided by collections module.

The next series of posts will dive deep into the above mentioned container types provided by collections module.

Stay Tuned !


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK