If Python VM executes byte-code, where are the byte-code for non-import modules?
<p>I understand a few things based on the following link (I could be wrong!):</p>

<p><a href="http://docs.python.org/2/glossary.html#term-bytecode" rel="nofollow">http://docs.python.org/2/glossary.html#term-bytecode</a></p>

<ol>
<li><p><code>.pyc</code> is a cached file and is only generated if the module is imported somewhere else</p></li>
<li><p><code>.pyc</code> is to help loading performance, not execution performance.</p></li>
<li><p>running <code>python foo.py</code> does not generate <code>foo.pyc</code> unless <code>foo</code> is imported somewhere.</p></li>
<li><p>Python has a bytecode compiler (used to generate <code>.pyc</code>)</p></li>
<li><p>Python's virtual machine executes byte-code.</p></li>
</ol>

<p>So, when I run <code>python foo.py</code>, if <code>foo.py</code> is not imported anywhere, does Python actually create an in-memory bytecode?</p>

<p>The missing <code>.pyc</code> seems to break the idea of Python VM.</p>

<p>This question is extended to code execution in Python interpreter (running <code>python</code> in the terminal). I believe CPython (or just about any language implementation) can't do pure interpretation. </p>

<p>I think the core of the question is: Does the VM actually read the <code>.pyc</code> file? I assume VM loads the <code>.pyc</code> into the execution environment.</p>
