title: Checking if two strings are permutations of each other in Python
body: <p>I'm checking if two strings <code>a</code> and <code>b</code> are permutations of each other, and I'm wondering what the ideal way to do this is in Python. From the Zen of Python, "There should be one -- and preferably only one -- obvious way to do it," but I see there are at least two ways:</p>
  
  <pre><code>sorted(a) == sorted(b)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>all(a.count(char) == b.count(char) for char in a)
  </code></pre>
  
  <p>but the first one is slower when (for example) the first char of <code>a</code> is nowhere in <code>b</code>, and the second is slower when they are actually permutations.</p>
  
  <p>Is there any better (either in the sense of more Pythonic, or in the sense of faster on average) way to do it? Or should I just choose from these two depending on which situation I expect to be most common?</p>