I have a tuple/list inside a list like this:
[(\'foo\',\'bar\'),(\'foo1\',\'bar1\'),(\'foofoo\',\'barbar\')]
What is the fastest way in pyt
You can use reversed
like this:
tuple(reversed((1, 2)) == (2, 1)
To apply it to a list, you can use map
or a list comprehension:
map(tuple, map(reversed, tuples)) # map
[tuple(reversed(x)) for x in tuples] # list comprehension
If you're interested primarily in runtime speed, I can only recommend that you profile the various approaches and pick the fastest.