Import Module Benchmark
<p>I have been doing some performance testing and got rather curious at my latest findings.</p>

<pre><code>&gt;&gt;&gt; timeit("import timeit")
0.8010718822479248
&gt;&gt;&gt; timeit("from timeit import timeit")
1.3421258926391602
</code></pre>

<p>How can importing the <strong>whole module be faster</strong>, than importing just a <strong>specific part</strong> ?</p>

<p>Based on the answers, I have been doing some tests and I came across the following:</p>

<pre><code>&gt;&gt;&gt; timeit("x = timeit.timeit", setup="import timeit")
0.09205102920532227
&gt;&gt;&gt; timeit("x = timeit", setup="from timeit import timeit")
0.0244600772857666
</code></pre>

<p>Regarding <strong>performance</strong>, if you plan on using a <em>class/function/submodule</em> a lot, it takes less time if you specify where to import from and can  offset or even make up for the time lost in the import.</p>

<p><code>import timeit</code> will get the module directly while <code>from timeit import timeit</code> will take time browsing entire timeit module. Hence the results.</p>

python performance time