Open links in new tab
  1. collections — Container datatypes — Python 3.14.3 documentation

  1. Python's collections module provides specialized container datatypes that offer alternatives to Python’s general-purpose built-in containers like dict, list, set, and tuple. These specialized containers are designed to handle specific programming problems more efficiently and elegantly.

    Key Components of the Collections Module

    1. namedtuple

    namedtuple is a factory function for creating tuple subclasses with named fields. This allows for more readable and self-documenting code by accessing fields by name instead of position index.

    from collections import namedtuple

    # Define a namedtuple class
    Point = namedtuple('Point', ['x', 'y'])

    # Create an instance of Point
    p = Point(11, y=22)

    # Access elements using attributes
    print(p.x) # 11
    print(p.y) # 22
    Copied!

    2. deque

    deque (double-ended queue) is a list-like container with fast appends and pops on either end. It is optimized for memory-efficient and quick operations.

    Feedback
  2. Python Collections Module - GeeksforGeeks

    Jul 26, 2025 · The collections module in Python provides specialized containers (different from general purpose built-in containers like dict, list, tuple and set). These specialized containers are designed to …

  3. Python collections Module - W3Schools

    The collections module provides specialized container datatypes. Use it for efficient alternatives to built-in containers, like named tuples, counters, default dicts, deques, and ordered dicts.

  4. Python's collections: A Buffet of Specialized Data Types

    In this tutorial, you'll learn all about the series of specialized container data types in the collections module from the Python standard library.

  5. Python Collections Module - Online Tutorials Library

    The Python collections contains different type of containers. The container is an object which holds different elements and can access the elements and iterate over the object.

  6. Understanding Collections in Python Complete Guide

    Python’s collections module provides a set of specialized container data types that extend the functionality of built-in data structures. These advanced containers …

  7. Power of Python Collection Framework : For Beginners

    Jul 6, 2023 · Learn how to use Python's built-in data structures and algorithms through its Collection Framework. Explore lists, tuples, sets, dictionaries, deques, …

  8. Python's `collections` Module: A Comprehensive Guide

    Jan 26, 2025 · In this blog post, we will explore the fundamental concepts, usage methods, common practices, and best practices related to the `collections` module in Python.

  9. All You Need to Know About the “collections” Module in …

    Mar 15, 2025 · This guide will take you through every essential data structure in the collections module with detailed explanations, why they are important, how they …

  10. Python Collections Module - TutorialsTeacher.com

    The collections module provides alternatives to built-in container data types such as list, tuple and dict.