Why is statistics.mean() so slow?
<p>I compared the performance of the <code>mean</code> function of the <code>statistics</code> module with the simple <code>sum(l)/len(l)</code> method and found the <code>mean</code> function to be very slow for some reason. I used <code>timeit</code> with the two code snippets below to compare them, does anyone know what causes the massive difference in execution speed? I'm using Python 3.5.</p>

<pre><code>from timeit import repeat
print(min(repeat('mean(l)',
                 '''from random import randint; from statistics import mean; \
                 l=[randint(0, 10000) for i in range(10000)]''', repeat=20, number=10)))
</code></pre>

<p>The code above executes in about 0.043 seconds on my machine.</p>

<pre><code>from timeit import repeat
print(min(repeat('sum(l)/len(l)',
                 '''from random import randint; from statistics import mean; \
                 l=[randint(0, 10000) for i in range(10000)]''', repeat=20, number=10)))
</code></pre>

<p>The code above executes in about 0.000565 seconds on my machine.</p>