title: c++11 regex slower than python
body: <p>hi i would like to understand why the following code which does a split string split using regex</p>
  
  <pre><code>#include&lt;regex&gt;
  #include&lt;vector&gt;
  #include&lt;string&gt;
  
  std::vector&lt;std::string&gt; split(const std::string &amp;s){
      static const std::regex rsplit(" +");
      auto rit = std::sregex_token_iterator(s.begin(), s.end(), rsplit, -1);
      auto rend = std::sregex_token_iterator();
      auto res = std::vector&lt;std::string&gt;(rit, rend);
      return res;
  }
  
  int main(){
      for(auto i=0; i&lt; 10000; ++i)
         split("a b c", " ");
      return 0;
  }
  </code></pre>
  
  <p>is slower then the following python code</p>
  
  <pre><code>import re
  for i in range(10000):
      re.split(' +', 'a b c')
  </code></pre>
  
  <p>here's </p>
  
  <pre><code>&gt; python test.py  0.05s user 0.01s system 94% cpu 0.070 total
  ./test  0.26s user 0.00s system 99% cpu 0.296 total
  </code></pre>
  
  <p>Im using clang++ on osx.</p>
  
  <p>compiling with -O3 brings it to  down to <code>0.09s user 0.00s system 99% cpu 0.109 total</code></p>