About 90,500 results
Open links in new tab
  1. In Python, when to use a Dictionary, List or Set?

    Jul 1, 2019 · When you want to collect an immutable ordered list of elements, use a tuple. (For example, when you want a (name, phone_number) pair that you wish to use as an element in …

  2. What are differences between List, Dictionary and Tuple in Python ...

    Sep 6, 2010 · List is a mutable type meaning that lists can be modified after they have been created. A tuple is similar to a list except it is immutable. There is also a semantic difference …

  3. Python 3: When to use dict, when list of tuples? - Stack Overflow

    Jan 20, 2013 · To get the names of the prisoners using the dictionary, you just do this: d.values() To do the same thing with the list of tuples you would need to do this: names = [] for tup in l: …

  4. Python memory consumption: dict VS list of tuples

    The size of the dictionary is larger at that point, at least for me.) Martijn is right that the tuples in the list of tuples add to the memory overhead, canceling out the memory advantage of lists …

  5. python performance - list of tuples or dictionary for relationships?

    Dec 4, 2012 · Your second example could be better written as for s, repl in tuple_list: address = address.replace(s, repl). – Steven Rumbalski Commented Dec 4, 2012 at 17:06

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

    Mar 9, 2009 · we can also change the dictionary inside tuple as . my_tuple[4]['a'] = 500 which will make the overall tuple looks like (10, 20, 30, [400, 500], {'a': 500}) This happens because list …

  7. Python dictionary vs list, which is faster? - Stack Overflow

    Aug 13, 2016 · In Python, the average time complexity of a dictionary key lookup is O(1), since they are implemented as hash tables. The time complexity of lookup in a list is O(n) on …

  8. python - List vs tuple, when to use each? - Stack Overflow

    Since the edit was rejected and there is no way to add this as an answer, here's a comment to add more info: Copying or cloning a tuple is not as straightforward as a list or dictionary. For …

  9. When to use a tuple vs list vs dictionary in python? [closed]

    I was having a discussion with a friend on Facebook today and he's just starting to learn python, as we were discussing he said this, "I've written a million lines of code over the years and the …

  10. python - What is the major difference between list of tuples and a ...

    A list of tuples is an array-like data-structure. This means that if we want to look up a key (referring to the first entry in the tuple), we have to look through every value in the list until we …