def swap(a, b): return b, a
Or since this is presumably python, just inline it without a function:
(a, b) = (b, a)
Or since this is presumably python, just inline it without a function: