Notes
Feature Array Set Tuple List Dictionary
Definition Fixed-type Unordered Ordered, Ordered, Unordered
sequence of collection of immutable mutable collection of
elements. unique sequence of sequence of key-value
elements. elements. elements. pairs.
Mutable Yes Yes No Yes Keys: No,
Values: Yes
Order Yes No Yes Yes No (insertion
order preserved
from Python
3.7+)
Duplicates Yes No Yes Yes Keys: No,
Values: Yes
Indexing Supported Not supported Supported Supported Not applicable
Slicing Supported Not supported Supported Supported Not applicable
Heterogeneous No Yes Yes Yes Yes (keys and
Elements values)
Type Must be of No type No type No type Keys must be
Constraints same type constraint constraint constraint immutable
(e.g., strings,
tuples)
Syntax array('i', [1, {1, 2, 3} (1, 2, 3) [1, 2, 3] {1: 'a', 2: 'b'}
2, 3])
Access Method Via index Via iteration Via index Via index Via key
Use Cases For fixed- Membership Immutable General- Lookups by
type tests, removing ordered purpose key, storing
numerical duplicates collections mutable related data
data sequence
Performance Efficient for Fast Fast read-only Slower than Fast lookups
numerical membership access tuples for for keys
operations tests read-only
Memory More Depends on size More Consumes Memory use
Efficiency efficient for and number of memory- more memory depends on
elements than tuples
numeric efficient than key-value pair
types lists size
Example arr = s = {1, 2, 3} t = (1, 2, 3) l = [1, 2, 3] d = {'a': 1, 'b':
array('i', [1, 2}
2, 3])
Key Differences:
• Array is used for homogeneously typed data (e.g., all integers or all floats).
• Set is used for unordered collections where uniqueness is important.
• Tuple is immutable and ordered, used for fixed collections of elements.
• List is mutable and ordered, suitable for general-purpose collections.
• Dictionary is used for mapping unique keys to values, ideal for lookups.