title: a,b = b,a in python vs std::swap() in C++
body: <p>I know that <code>a,b = b,a</code> is basically assigning a tuple <code>(a,b)</code> the values of another tuple <code>(b,a)</code>. This is, essentially, swapping the values form <code>a</code> to <code>b</code> and from <code>b</code> to <code>a</code>. Thus, causing a "swap".</p>
  
  <p>This is the functionality of the <code>swap()</code> function in C++.</p>
  
  <p>From research, I have seen that C++'s <code>swap()</code> function uses a third temporary variable to perform the swap. I haven't been able to find how is <code>a,b = b,a</code> implemented in python.</p>
  
  <p><strong>How is <code>a,b = b,a</code> implemented?</strong></p>
  
  <p><strong>Does python also use a third temporary variable? If it doesn't, how does it work?</strong></p>
  
  <p><strong>How do both operations compare in terms of speed?</strong> I'm guessing that if python also uses a third variable, the difference in execution time would be due to python being interpreted.</p>
  
  <p><strong>Edit:</strong> All answers are great, but the community seems to think that Sapan's is the best one. Also thanks to a_guest, whom, although didn't post an answer, gave us a great deal of information in the comments. Also: everyone seems to agree that <code>swap()</code> is faster just because its C++. I don't necessarily agree with that. Python can be very fast if run as a frozen binary.</p>