How is python running faster than C and C++? : <p>I have made simple program which just prints 1 million numbers on screen, python was taking about 5.2 seconds.
I thought C and C++ should do it faster but both are taking about 8 seconds every time I run. How these are slower than python?</p>

<p>python code:</p>

<pre><code>import time

start = time.time()

i = 0
while i &lt; 1000000:
    print(i)
    i += 1

time_taken = time.time() - start
print(("Program took %s seconds." % (time_taken)))
</code></pre>

<blockquote>
  <p>Program took 5.204254150390625 seconds.</p>
</blockquote>

<p>C code:</p>

<pre><code>#include&lt;stdio.h&gt;

int main()
{
    for( int i = 0 ; i &lt; 1000000 ; ++i )
        printf("%d\n", i);
}
</code></pre>

<blockquote>
  <p>Time taken: 8.582 seconds.</p>
</blockquote>

<p>C++ code:</p>

<pre><code>#include&lt;iostream&gt;

using namespace std;

int main()
{
    for( int i = 0 ; i &lt; 1000000 ; ++i)
    cout&lt;&lt;i&lt;&lt;endl;
}
</code></pre>

<blockquote>
  <p>Time taken: 8.778 seconds.</p>
</blockquote>

<p>While when I run this:</p>

<pre><code>import time

start = time.time()

print(*range(1000000))

time_taken = time.time() - start
print(("Program took %s seconds." % (time_taken)))
</code></pre>

<blockquote>
  <p>Program took 60.77405118942261 seconds.</p>
</blockquote>

<p>How is python's built in function is working slower than trivial version of program?</p>
