title: Python faster than C++ in deserializing json. Why? Is the json library in Python 3 written in C/C++ or other low-level language?
body: <p>C/C++ is well known for being in many cases faster than python. I made a test in this direction.</p>
  
  <p>I have a large (beautified) JSON file with 2200 lines. The test consisted in reading the file, deserializing the data in memory (I used dictionaries as data structure) and displaying the content.</p>
  
  <p>I performed the test both in python using the built-in <a href="https://docs.python.org/3.6/library/json.html" rel="nofollow noreferrer"><code>json</code></a> library and in C++ using the external <a href="https://github.com/nlohmann/json" rel="nofollow noreferrer">nlohmann</a> JSON library.</p>
  
  <p>After a few runs, I had the shock to see that C++ takes 0.01 seconds and Python 3 takes about 0.001 seconds, which is almost 10 times faster!</p>
  
  <p>I searched in the docs but I did not find information about what was used in writing the <code>json</code> library.</p>
  
  <p>C++:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string.h&gt;
  #include &lt;boost/property_tree/json_parser.hpp&gt;
  #include &lt;boost/property_tree/ptree.hpp&gt;
  #include "nlohmann/json.hpp"
  using namespace std;
  using json = nlohmann::json;
  namespace pt = boost::property_tree;
  #include &lt;ctime&gt;
  
  int main()
  {
  
      ifstream input;
      input.open("input.json");
  
      json json_data;
  
      input &gt;&gt; json_data; 
  
      cout &lt;&lt; json_data &lt;&lt; endl;
  
    return 0;
  }
  </code></pre>
  
  <p>And Python:</p>
  
  <pre><code>import json
  from time import time
  
  t1 = time()
  with open('output.json','r+') as f:
      f = json.load(f)
  
      print(f)
  t2 = time()
  elapsed = t2 - t1
  
  print('elapsed time: '+str(elapsed))
  </code></pre>
  
  <p>Final question, is the <code>json</code> Python library by any chance written in any low level language and this is the main reason for performance, or is just pure Python?</p>