range Object Characteristics
1 min read ·
Type of range()
The
range() function returns an object of type range.The output confirms that it is not a list.
Immutability
Range objects are immutable.
Once created, their start stop and step values cannot be modified.
This results in an error because range objects do not support item assignment.
Lazy Evaluation
range() uses lazy evaluation.Values are generated only when accessed during iteration.
This behavior makes range memory efficient even for very large sequences.
Important
Lazy evaluation allows range() to represent large sequences without storing them in memory.