title: Very poor boost::lexical_cast performance
body: <p>Windows XP SP3. Core 2 Duo 2.0 GHz.
  I'm finding the boost::lexical_cast performance to be extremely slow. Wanted to find out ways to speed up the code. Using /O2 optimizations on visual c++ 2008 and comparing with java 1.6 and python 2.6.2 I see the following results.</p>
  
  <p><strong>Integer casting:</strong></p>
  
  <pre><code>c++: 
  std::string s ;
  for(int i = 0; i &lt; 10000000; ++i)
  {
      s = boost::lexical_cast&lt;string&gt;(i);
  }
  
  java:
  String s = new String();
  for(int i = 0; i &lt; 10000000; ++i)
  {
      s = new Integer(i).toString();
  }
  
  python:
  for i in xrange(1,10000000):
      s = str(i)
  </code></pre>
  
  <p>The times I'm seeing are </p>
  
  <p>c++: 6700 milliseconds</p>
  
  <p>java: 1178 milliseconds</p>
  
  <p>python: 6702 milliseconds</p>
  
  <p>c++ is as slow as python and 6 times slower than java.</p>
  
  <p><strong>Double casting:</strong></p>
  
  <pre><code>c++:
  std::string s ;
  for(int i = 0; i &lt; 10000000; ++i)
  {
      s = boost::lexical_cast&lt;string&gt;(d);
  }
  
  java:
  String s = new String();
  for(int i = 0; i &lt; 10000000; ++i)
  {
      double d = i*1.0;
      s = new Double(d).toString();
  }
  
  python:
  for i in xrange(1,10000000):
      d = i*1.0
      s = str(d)
  </code></pre>
  
  <p>The times I'm seeing are</p>
  
  <p>c++: 56129 milliseconds</p>
  
  <p>java: 2852 milliseconds</p>
  
  <p>python: 30780 milliseconds</p>
  
  <p>So for doubles c++ is actually half the speed of python and 20 times slower than the java solution!!. Any ideas on improving the boost::lexical_cast performance? Does this stem from the poor stringstream implementation or can we expect a general 10x decrease in performance from using the boost libraries. </p>