It depends on what you are intending to do with it.
Sets are significantly faster when it comes to determining if an object is present in the set (as in x in s
), but are slower than lists when it comes to iterating over their contents.
You can use the timeit module to see which is faster for your situation.
Related Posts:
- In Python, when to use a Dictionary, List or Set?
- Get difference between two lists
- What is the difference between Python’s list methods append and extend?
- Fastest way to check if a value exists in a list
- Python set to list
- Replace values in list using Python
- Add list to set?
- How to make a set of lists
- How can I reverse a list in Python?
- Difference between del, remove, and pop on lists
- How can I reverse a list in Python?
- Python – TypeError: ‘int’ object is not iterable
- Understanding slice notation
- Understanding slice notation
- TypeError: list indices must be integers or slices, not str
- IndexError: list index out of range and python
- Python – TypeError: ‘int’ object is not iterable
- How to convert list to string [duplicate]
- How do I get the number of elements in a list?
- Finding the index of an item in a list
- Finding the index of an item in a list
- Accessing the index in ‘for’ loops?
- How to make a flat list out of a list of lists
- Removing duplicates in lists
- What does the list() function do in Python?
- List changes unexpectedly after assignment. Why is this and how can I prevent it?
- Why does this iterative list-growing code give IndexError: list assignment index out of range?
- Append values to a set in Python
- TypeError: ‘float’ object is not subscriptable
- Is there a short contains function for lists?
- TypeError: ‘float’ object is not subscriptable
- Transpose/Unzip Function (inverse of zip)?
- appending list but error ‘NoneType’ object has no attribute ‘append’
- Check if something is (not) in a list in Python
- Python: finding an element in a list [duplicate]
- How to avoid “RuntimeError: dictionary changed size during iteration” error?
- How to avoid “RuntimeError: dictionary changed size during iteration” error?
- Finding the average of a list
- Writing a list to a file with Python
- How can I remove a key from a Python dictionary?
- How do I concatenate two lists in Python?
- if else in a list comprehension
- Does Python have an ordered set?
- How can I randomly select an item from a list?
- Print a list in reverse order with range()?
- Convert Set to List without creating new List
- Get unique values from a list in python [duplicate]
- How can I count the occurrences of a list item?
- TypeError: ‘list’ object cannot be interpreted as an integer
- Why is it string.join(list) instead of list.join(string)?
- Why is it string.join(list) instead of list.join(string)?
- How do I concatenate two lists in Python?
- if else in a list comprehension
- Does Python have an ordered set?
- Finding median of list in Python
- Python List vs. Array – when to use?
- How to find all occurrences of an element in a list
- Get list from pandas dataframe column or row?
- Finding and replacing elements in a list
- How to find all the indexes of a recurring item in a list?
- ValueError: max() arg is an empty sequence
- Remove list from list in Python
- How can you profile a Python script?
- python – if not in list
- How do I concatenate two lists in Python?
- How can I compare two lists in python and return matches
- How can I remove a key from a Python dictionary?
- Append integer to beginning of list in Python
- Most efficient way to map function over numpy array
- List comprehension on a nested list?
- Union of two lists in Python
- Python: Array v. List
- Get unique values from a list in python
- ‘list’ object has no attribute ‘shape’
- Writing a list to a file with Python
- How do I check if a list is empty?
- How to sort a set in python?
- Empty set literal?
- Python: Get the first character of the first string in a list?
- Understanding slice notation
- How do I find the duplicates in a list and create another list with them?
- What’s the idiomatic syntax for prepending to a short python list?
- How to remove an element from a list by index
- Apply function to each element of a list
- Creating 2D dictionary in Python
- TypeError: unsupported operand type(s) for -: ‘list’ and ‘list’
- Remove all occurrences of a value from a list?
- Converting Dictionary to List?
- AttributeError: ‘list’ object has no attribute ‘replace’ when trying to remove character
- How to deep copy a list?
- Python return list from function
- TypeError: list indices must be integers or slices, not str
- How to check if a string is a substring of items in a list of strings?
- Whats the difference between ‘for x in list:’ and ‘for x in list[:]:’
- Removing Punctuation From Python List Items
- Check if two unordered lists are equal
- ‘list’ object has no attribute ‘shape’
- How do I find the duplicates in a list and create another list with them?
- How can I compare two lists in python and return matches