Python Data StructureGet more with collections!

time to read 1 min | 97 words

In addition to Python’s built-in data structures (such as tuples, dicts, and lists), a library module called collections provides data structures with additional features, some of which are specializations of the built-in ones.

Import the module:

import collections

Specialized container datatypes are usually dict subclasses or wrappers around other classes like lists, tuples, etc.

Notable implementations are :

  • the Counter class used for counting hashable objects.
  • defaultdict class used as a faster implementation of a specialised dictionary.
  • namedtuple class used for defining a meaning for every position in a tuple, often useful with databases or CSV files.

This is a post in the Python Data Structure series.
Other posts in this series:

  1. May 03, 2017 Enhance your tuples
  2. May 02, 2017 Get more with collections!
  3. Dec 26, 2016 Queue in Python - Part 3
  4. Nov 02, 2016 Queue in Python - Part 2
  5. Nov 02, 2016 Queue in Python - Part 1

Related Post:

  1. May 25, 2017 New interesting data structures in Python 3
  2. May 22, 2017 Keyword argument demystify
  3. May 04, 2017 Looping techniques in Python
  4. May 03, 2017 Enhance your tuples
  5. May 01, 2017 There is more to copying
  6. Apr 30, 2017 Implementing weak references in Python
  7. Apr 29, 2017 Translating Scanner tokens into primitive types
  8. Apr 28, 2017 Listing a file system's root directories
  9. Apr 27, 2017 The Console class
  10. Apr 26, 2017 Next, Function or Method ?
  11. Apr 24, 2017 Generator Expressions
  12. Apr 23, 2017 Yield Keyword
  13. Apr 21, 2017 What are Generators?
  14. Apr 16, 2017 Lambda Functions in Python
  15. Apr 06, 2017 Function in Python are First-Class Object
  16. Apr 05, 2017 Django 1.11 Release Note a Reading
  17. Apr 03, 2017 One Hell Named JSON
  18. Dec 26, 2016 Queue in Python - Part 3
  19. Nov 02, 2016 Queue in Python - Part 2
  20. Nov 02, 2016 Queue in Python - Part 1