tuple_operations.rst 732 B

123456789101112131415161718192021222324252627282930313233
  1. .. _tuple-ops:
  2. Native tuple operations
  3. =======================
  4. These ``tuple`` operations have fast, optimized implementations. Other
  5. tuple operations use generic implementations that are often slower.
  6. Unless mentioned otherwise, these operations apply to both fixed-length
  7. tuples and variable-length tuples.
  8. Construction
  9. ------------
  10. * ``item0, ..., itemN`` (construct a tuple)
  11. * ``tuple(lst: list)`` (construct a variable-length tuple)
  12. * ``tuple(lst: Iterable)`` (construct a variable-length tuple)
  13. Operators
  14. ---------
  15. * ``tup[n]`` (integer index)
  16. * ``tup[n:m]``, ``tup[n:]``, ``tup[:m]`` (slicing)
  17. Statements
  18. ----------
  19. * ``item0, ..., itemN = tup`` (for fixed-length tuples)
  20. Functions
  21. ---------
  22. * ``len(tup: tuple)``