DEV Community

Cover image for Python's Collections Module: Introduction
Kathan Vakharia
Kathan Vakharia

Posted on • Edited on

2 1

Python's Collections Module: Introduction

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 !

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay