Skip to content

Latest commit

 

History

History
20 lines (16 loc) · 715 Bytes

82os-python-tuples.md

File metadata and controls

20 lines (16 loc) · 715 Bytes

Python Tuples

#python #programming #language #efficiency

  • Tuples: Records if the same information on the same position
  • Can be used as immutable list if its size does not change
    • Use less memory
  • Inside mutable objects tuple does not change, but a new tuple is created [[1zto-shallow-and-deep-copy]]
  • They are two subclasses of tuples used to store records/hold data. They are
    • [[01o9-collections-namedtuple]]#
    • [[07fk-typing-namedtuple]]#
  • How to type tuples: [[o4v3-typing-tuple]]#

Warning

BUG: Tuple with mutable items can be a source of bugs. AVOID!

Warning

sort return a new object for tuple. Take a look on [[pcvu-sort-and-sorted]].

References

Ramalho, 2022, Chapter 1