abstract data type (ADT)
An abstract data type, or ADT, is a model of a data structure defined by the operations it supports and how those operations behave, independent of how they are implemented. It specifies what can be done with the data, not how the data is stored internally.
This separation between interface and implementation is the central idea. A stack, for example, is defined by its push and pop operations and by the rule that the last item pushed is the first one popped. That contract holds whether the stack is backed by an array or a linked list, and the calling code talks only to the operations:
Classic examples include the stack, the queue, the list, the set, and the map. An abstract data type is a specification, while a data structure is a concrete way to fulfill it, so the same ADT can have several implementations with different performance.
Describing data in terms of an ADT lets designers reason about behavior before committing to an implementation and its time complexity. Object-oriented languages express ADTs through classes and interfaces, and Python’s collections.abc module defines abstract base classes in this spirit.
Related Resources
Tutorial
Implementing Interfaces in Python: ABCs and Protocols
Learn how to implement interfaces in Python using abstract base classes, Protocols, and duck typing, and enforce method contracts cleanly.
For additional information on related topics, take a look at the following resources:
- Common Python Data Structures (Guide) (Tutorial)
- Stacks and Queues: Selecting the Ideal Data Structure (Course)
- Python Stacks, Queues, and Priority Queues in Practice (Tutorial)
- How to Implement a Python Stack (Tutorial)
- Python's deque: Implement Efficient Queues and Stacks (Tutorial)
- The Python heapq Module: Using Heaps and Priority Queues (Tutorial)
- Implementing a Stack in Python (Course)
- Python Interfaces: Object-Oriented Design Principles (Course)
- Implementing Interfaces in Python: ABCs and Protocols (Quiz)
- Records and Sets: Selecting the Ideal Data Structure (Course)
- Dictionaries and Arrays: Selecting the Ideal Data Structure (Course)
- Python Stacks, Queues, and Priority Queues in Practice (Quiz)