About 108,000 results
Open links in new tab
  1. python - List vs tuple, when to use each? - Stack Overflow

    Using a tuple instead of a list is like having an implied assert statement that this data is constant, and that special thought (and a specific function) is required to override that. Some tuples can …

  2. python - What's the difference between lists and tuples ... - Stack ...

    Mar 9, 2009 · In a list the values all have the same type and the length is not fixed. So the difference is very obvious. Finally there is the namedtuple in Python, which makes sense …

  3. Are tuples more efficient than lists in Python? - Stack Overflow

    Retrieving elements from a tuple are very slightly faster than from a list. Because, in CPython, tuples have direct access (pointers) to their elements, while lists need to first access another …

  4. What is the difference between lists and tuples in Python?

    Jul 28, 2010 · A useful variant of tuple is its sub-type collections.namedtuple (requires Python 2.6 or better) which lets you access items by name (with attribute syntax) as well as by index (the …

  5. Python typing: tuple[str] vs tuple[str, ...] - Stack Overflow

    Apr 25, 2022 · 22 giving a tuple type with ellipsis means that number of elements in this tuple is not known, but type is known:

  6. python - Static typing in python3: list vs List - Stack Overflow

    Oct 3, 2018 · 41 This question already has answers here: Using List/Tuple/etc. from typing vs directly referring type as list/tuple/etc (3 answers)

  7. Python Sets vs Lists - Stack Overflow

    In Python 2, set is always the slowest. or is the fastest for 2 to 3 literals, and tuple and list are faster with 4 or more literals. I couldn't distinguish the speed of tuple vs list.

  8. python - Using List/Tuple/etc. from typing vs directly referring …

    Sep 12, 2016 · 348 Until Python 3.9 added support for type hinting using standard collections, you had to use typing.Tuple and typing.List if you wanted to document what type the contents of …

  9. python - what is difference betwen string and tuple? - Stack …

    Mar 14, 2019 · Tuple they are immutable like strings and sequence like lists.They are used to store data just like list, just like string you cannot update or edit the tuple to change it you have …

  10. What's the difference between list and List in Python 3.8

    For type annotations, in Python 3.8 versions and earlier, it was explicitly required to import List as a valid type. So, we had to do something like from typing import List. Why did we have to crea...