title: Ignore case in Python strings
body: <p>What is the easiest way to compare strings in Python, ignoring case?</p>
  
  <p>Of course one can do (str1.lower() &lt;= str2.lower()), etc., but this created two additional temporary strings (with the obvious alloc/g-c overheads).</p>
  
  <p>I guess I'm looking for an equivalent to C's stricmp().</p>
  
  <p>[Some more context requested, so I'll demonstrate with a trivial example:]</p>
  
  <p>Suppose you want to sort a looong list of strings. You simply do theList.sort().
  This is O(n * log(n)) string comparisons and no memory management (since all
  strings and list elements are some sort of smart pointers). You are happy.</p>
  
  <p>Now, you want to do the same, but ignore the case (let's simplify and say
  all strings are ascii, so locale issues can be ignored).
  You can do theList.sort(key=lambda s: s.lower()), but then you cause two new 
  allocations per comparison, plus burden the garbage-collector with the duplicated
  (lowered) strings. 
  Each such memory-management noise is orders-of-magnitude slower than simple string comparison.</p>
  
  <p>Now, with an in-place stricmp()-like function, you do: theList.sort(cmp=stricmp)
  and it is as fast and as memory-friendly as theList.sort(). You are happy again.</p>
  
  <p>The problem is any Python-based case-insensitive comparison involves implicit string 
  duplications, so I was expecting to find a C-based comparisons (maybe in module string).</p>
  
  <p>Could not find anything like that, hence the question here.
  (Hope this clarifies the question).</p>