Related questions
Convert list to tuple in Python
I'm trying to convert a list to a tuple.
Most solutions on Google offer the following code:
l = [4,5,6]
tuple(l)
However, the code results in an error message when I run it:
TypeError: 'tuple' object is not callable
How can …
Elegant way to perform tuple arithmetic
What is the most elegant and concise way (without creating my own class with operator overloading) to perform tuple arithmetic in Python 2.7?
Lets say I have two tuples:
a = (10, 10)
b = (4, 4)
My intended result is
c = a - b = (6, 6)
I currently …
Why do tuples take less space in memory than lists?
A tuple takes less memory space in Python:
>>> a = (1,2,3)
>>> a.__sizeof__()
48
whereas lists takes more memory space:
>>> b = [1,2,3]
>>> b.__sizeof__()
64
What happens internally on the Python memory management?