<i id='wgEuN'><tr id='wgEuN'><dt id='wgEuN'><q id='wgEuN'><span id='wgEuN'><b id='wgEuN'><form id='wgEuN'><ins id='wgEuN'></ins><ul id='wgEuN'></ul><sub id='wgEuN'></sub></form><legend id='wgEuN'></legend><bdo id='wgEuN'><pre id='wgEuN'><center id='wgEuN'></center></pre></bdo></b><th id='wgEuN'></th></span></q></dt></tr></i><div id='wgEuN'><tfoot id='wgEuN'></tfoot><dl id='wgEuN'><fieldset id='wgEuN'></fieldset></dl></div>

        <bdo id='wgEuN'></bdo><ul id='wgEuN'></ul>

        <small id='wgEuN'></small><noframes id='wgEuN'>

      1. <tfoot id='wgEuN'></tfoot>
        <legend id='wgEuN'><style id='wgEuN'><dir id='wgEuN'><q id='wgEuN'></q></dir></style></legend>

        为什么python在解释之前将源代码编译为字节码?

        时间:2023-07-04
            <i id='02vc8'><tr id='02vc8'><dt id='02vc8'><q id='02vc8'><span id='02vc8'><b id='02vc8'><form id='02vc8'><ins id='02vc8'></ins><ul id='02vc8'></ul><sub id='02vc8'></sub></form><legend id='02vc8'></legend><bdo id='02vc8'><pre id='02vc8'><center id='02vc8'></center></pre></bdo></b><th id='02vc8'></th></span></q></dt></tr></i><div id='02vc8'><tfoot id='02vc8'></tfoot><dl id='02vc8'><fieldset id='02vc8'></fieldset></dl></div>

            <small id='02vc8'></small><noframes id='02vc8'>

              <tbody id='02vc8'></tbody>
              1. <legend id='02vc8'><style id='02vc8'><dir id='02vc8'><q id='02vc8'></q></dir></style></legend>

                  <bdo id='02vc8'></bdo><ul id='02vc8'></ul>
                  <tfoot id='02vc8'></tfoot>
                  本文介绍了为什么python在解释之前将源代码编译为字节码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  为什么python在解释之前要把源码编译成字节码?

                  Why python compile the source to bytecode before interpreting?

                  为什么不直接从源头解释?

                  Why not interpret from the source directly?

                  推荐答案

                  几乎没有解释器真正直接逐行解释代码——这实在是太低效了.几乎所有解释器都使用一些可以轻松执行的中间表示.此外,还可以对此中间代码进行小幅优化.

                  Nearly no interpreter really interprets code directly, line by line – it's simply too inefficient. Almost all interpreters use some intermediate representation which can be executed easily. Also, small optimizations can be performed on this intermediate code.

                  Python 还存储了这段代码,这对下次执行这段代码有很大的好处:Python 不再需要解析代码;解析是编译过程中最慢的部分.因此,字节码表示可以大大减少执行开销.

                  Python furthermore stores this code which has a huge advantage for the next time this code gets executed: Python doesn't have to parse the code anymore; parsing is the slowest part in the compile process. Thus, a bytecode representation reduces execution overhead quite substantially.

                  这篇关于为什么python在解释之前将源代码编译为字节码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何用 Python 编写抽象语法树的访问者模式? 下一篇:Python:EOFError:读取一行时出现EOF

                  相关文章

                  • <bdo id='p99Ml'></bdo><ul id='p99Ml'></ul>

                  <small id='p99Ml'></small><noframes id='p99Ml'>

                • <tfoot id='p99Ml'></tfoot>

                    1. <i id='p99Ml'><tr id='p99Ml'><dt id='p99Ml'><q id='p99Ml'><span id='p99Ml'><b id='p99Ml'><form id='p99Ml'><ins id='p99Ml'></ins><ul id='p99Ml'></ul><sub id='p99Ml'></sub></form><legend id='p99Ml'></legend><bdo id='p99Ml'><pre id='p99Ml'><center id='p99Ml'></center></pre></bdo></b><th id='p99Ml'></th></span></q></dt></tr></i><div id='p99Ml'><tfoot id='p99Ml'></tfoot><dl id='p99Ml'><fieldset id='p99Ml'></fieldset></dl></div>
                    2. <legend id='p99Ml'><style id='p99Ml'><dir id='p99Ml'><q id='p99Ml'></q></dir></style></legend>