Is there any reason why the next tuple is greater then the list?
>>> t = ( 1, 2, 3 )
>>> l = [ 1, 2, 3 ]
>>> t > l
True
>>> t < l
False
Tuples are more memory efficient than the lists. When it comes to the time efficiency, again tuples have a slight advantage over the lists especially when lookup to a value is considered. If you have data which is not meant to be changed in the first place, you should choose tuple data type over lists.
Tuple is a collection which is ordered and unchangeable. Allows duplicate members.
Tuples are stored in a single block of memory. Tuples are immutable so, It doesn't require extra space to store new objects. Lists are allocated in two blocks: the fixed one with all the Python object information and a variable-sized block for the data. It is the reason creating a tuple is faster than List.
We consider the tuple as duplicate if all the attribute values of two rows are the same. Redundancies between attributes and duplicate tuples must be detected.
In Python 2, any tuple is always compared as greater than any list - that's just the way it is defined in the language.
In Python 3, this is fixed, so that comparing tuples and lists gives TypeError: unorderable types: tuple() > list()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With