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

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

    <tfoot id='uwWJh'></tfoot>

        <bdo id='uwWJh'></bdo><ul id='uwWJh'></ul>
      <legend id='uwWJh'><style id='uwWJh'><dir id='uwWJh'><q id='uwWJh'></q></dir></style></legend>

        Python 比 C++ 更快更轻吗?

        时间:2023-09-15

              <tbody id='uiHU3'></tbody>
            <legend id='uiHU3'><style id='uiHU3'><dir id='uiHU3'><q id='uiHU3'></q></dir></style></legend>

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

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

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

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

                  本文介绍了Python 比 C++ 更快更轻吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我一直认为Python的优势是代码可读性和开发速度快,但是时间和内存使用不如C++.

                  I've always thought that Python's advantages are code readibility and development speed, but time and memory usage were not as good as those of C++.

                  这些统计数据让我印象深刻.

                  关于 Python 与 C++ 的时间和内存使用情况,您的经验告诉您什么?

                  What does your experience tell you about Python vs C++ time and memory usage?

                  推荐答案

                  我认为您对这些统计数据的理解有误.他们表明 Python 比 C++多达 400 倍,并且除了单个案例之外,Python 更像是一个内存占用者.不过,在源代码大小方面,Python 胜出.

                  I think you're reading those stats incorrectly. They show that Python is up to about 400 times slower than C++ and with the exception of a single case, Python is more of a memory hog. When it comes to source size though, Python wins flat out.

                  我使用 Python 的经验表明,在进行任何严重的数字运算时,Python 的速度比 C++ 慢 10 到 100 倍.造成这种情况的原因有很多,主要是: a) Python 是解释型的,而 C++ 是编译型的;b) Python 没有原语,包括内置类型(int、float 等)在内的一切都是对象;c) Python 列表可以保存不同类型的对象,因此每个条目必须存储有关其类型的附加数据.这些都严重阻碍了运行时和内存消耗.

                  My experiences with Python show the same definite trend that Python is on the order of between 10 and 100 times slower than C++ when doing any serious number crunching. There are many reasons for this, the major ones being: a) Python is interpreted, while C++ is compiled; b) Python has no primitives, everything including the builtin types (int, float, etc.) are objects; c) a Python list can hold objects of different type, so each entry has to store additional data about its type. These all severely hinder both runtime and memory consumption.

                  不过,这不是忽略 Python 的理由.即使有 100 倍的慢度因素,许多软件也不需要太多时间或内存.开发成本是Python以简洁明了的风格取胜的地方.这种开发成本的改善往往超过了额外的 CPU 和内存资源的成本.然而,如果没有,那么 C++ 就会获胜.

                  This is no reason to ignore Python though. A lot of software doesn't require much time or memory even with the 100 time slowness factor. Development cost is where Python wins with the simple and concise style. This improvement on development cost often outweighs the cost of additional cpu and memory resources. When it doesn't, however, then C++ wins.

                  这篇关于Python 比 C++ 更快更轻吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何将 vector::push_back()` 与结构一起使用? 下一篇:C++11:用 std::shared_ptr() 替换所有非拥有的原始指针

                  相关文章

                  最新文章

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

                    <tfoot id='5gUr0'></tfoot>
                  1. <small id='5gUr0'></small><noframes id='5gUr0'>

                    <legend id='5gUr0'><style id='5gUr0'><dir id='5gUr0'><q id='5gUr0'></q></dir></style></legend>
                      <bdo id='5gUr0'></bdo><ul id='5gUr0'></ul>