@@ -1182,58 +1182,58 @@ msgstr "我的程序太慢了。该如何加快速度?"
11821182msgid ""
11831183"That's a tough one, in general. First, here are a list of things to "
11841184"remember before diving further:"
1185- msgstr ""
1185+ msgstr "总的来说,这是个棘手的问题。首先,下面列出了深入了解前需要记住的事情: "
11861186
11871187#: ../../faq/programming.rst:1028
11881188msgid ""
11891189"Performance characteristics vary across Python implementations. This FAQ "
11901190"focusses on :term:`CPython`."
1191- msgstr ""
1191+ msgstr "不同的Python实现具有不同的性能特征。本常见问题解答的重点是 :term:`CPython` 。 "
11921192
11931193#: ../../faq/programming.rst:1030
11941194msgid ""
11951195"Behaviour can vary across operating systems, especially when talking about "
11961196"I/O or multi-threading."
1197- msgstr ""
1197+ msgstr "行为可能因操作系统而异,尤其是在谈论 I / O 或多线程时。 "
11981198
11991199#: ../../faq/programming.rst:1032
12001200msgid ""
12011201"You should always find the hot spots in your program *before* attempting to "
12021202"optimize any code (see the :mod:`profile` module)."
1203- msgstr ""
1203+ msgstr "在尝试优化任何代码 *前* ,应始终找到程序中的热点(请参阅 :mod:`profile` 模块)。 "
12041204
12051205#: ../../faq/programming.rst:1034
12061206msgid ""
12071207"Writing benchmark scripts will allow you to iterate quickly when searching "
12081208"for improvements (see the :mod:`timeit` module)."
1209- msgstr ""
1209+ msgstr "编写基准脚本将允许您在搜索改进时快速迭代(请参阅 :mod:`timeit` 模块)。 "
12101210
12111211#: ../../faq/programming.rst:1036
12121212msgid ""
12131213"It is highly recommended to have good code coverage (through unit testing or"
12141214" any other technique) before potentially introducing regressions hidden in "
12151215"sophisticated optimizations."
1216- msgstr ""
1216+ msgstr "强烈建议在可能引入隐藏在复杂优化中的回归之前,要有良好的代码覆盖率(通过单元测试或任何其他技术)。 "
12171217
12181218#: ../../faq/programming.rst:1040
12191219msgid ""
12201220"That being said, there are many tricks to speed up Python code. Here are "
12211221"some general principles which go a long way towards reaching acceptable "
12221222"performance levels:"
1223- msgstr ""
1223+ msgstr "话虽如此,加速Python代码有很多技巧。以下是一些可以达到可接受的性能水平的一般原则: "
12241224
12251225#: ../../faq/programming.rst:1044
12261226msgid ""
12271227"Making your algorithms faster (or changing to faster ones) can yield much "
12281228"larger benefits than trying to sprinkle micro-optimization tricks all over "
12291229"your code."
1230- msgstr ""
1230+ msgstr "使您的算法更快(或更改为更快的算法)可以产生比尝试在代码中使用微优化技巧更大的好处。 "
12311231
12321232#: ../../faq/programming.rst:1048
12331233msgid ""
12341234"Use the right data structures. Study documentation for the :ref:`bltin-"
12351235"types` and the :mod:`collections` module."
1236- msgstr ""
1236+ msgstr "使用正确的数据结构。参考文档 :ref:`bltin-types` 和 :mod:`collections` 模块。 "
12371237
12381238#: ../../faq/programming.rst:1051
12391239msgid ""
@@ -1245,6 +1245,9 @@ msgid ""
12451245"do sorting (and see the :ref:`sortinghowto` for examples of moderately "
12461246"advanced usage)."
12471247msgstr ""
1248+ "当标准库提供用于执行某些操作的原语时,可能(尽管不能保证)比您可能提出的任何替代方案更快。对于用C编写的原语,例如内置函数和一些扩展类型,这是真的。例如,请确保使用"
1249+ " :meth:`list.sort` 内置方法或相关的 :func:`sorted` 函数进行排序(有关适度高级用法的示例,请参阅 "
1250+ ":ref:`sortinghowto` )。"
12481251
12491252#: ../../faq/programming.rst:1059
12501253msgid ""
@@ -1254,6 +1257,7 @@ msgid ""
12541257"especially under the form of tiny functions or methods (which are also often"
12551258" detrimental to readability)."
12561259msgstr ""
1260+ "抽象倾向于创造间接性并迫使翻译更多地工作。如果间接级别超过完成的有用工作量,则程序将变慢。你应该避免过度抽象,特别是在微小的功能或方法的形式下(这通常也会对可读性产生不利影响)。"
12571261
12581262#: ../../faq/programming.rst:1065
12591263msgid ""
@@ -1266,12 +1270,18 @@ msgid ""
12661270"skills, you can also :ref:`write a C extension module <extending-index>` "
12671271"yourself."
12681272msgstr ""
1273+ "如果你已经达到纯Python允许的限制,那么有一些工具可以让你走得更远。例如, `Cython <http://cython.org>`_ "
1274+ "可以将稍微修改的Python代码版本编译为C扩展,并且可以在许多不同的平台上使用。 "
1275+ "Cython可以利用编译(和可选的类型注释)来使代码明显快于解释时的速度。如果您对C编程技能有信心,也可以自己编写 :ref:`write a C "
1276+ "extension module <extending-index>` 。"
12691277
12701278#: ../../faq/programming.rst:1075
12711279msgid ""
12721280"The wiki page devoted to `performance tips "
12731281"<https://wiki.python.org/moin/PythonSpeed/PerformanceTips>`_."
12741282msgstr ""
1283+ "专门介绍 `性能提示 <https://wiki.python.org/moin/PythonSpeed/PerformanceTips>`_ "
1284+ "的wiki页面。"
12751285
12761286#: ../../faq/programming.rst:1081
12771287msgid "What is the most efficient way to concatenate many strings together?"
@@ -1293,7 +1303,7 @@ msgstr ""
12931303
12941304#: ../../faq/programming.rst:1096
12951305msgid "(another reasonably efficient idiom is to use :class:`io.StringIO`)"
1296- msgstr ""
1306+ msgstr "(另一个合理有效的习惯用法是 :class:`io.StringIO` ) "
12971307
12981308#: ../../faq/programming.rst:1098
12991309msgid ""
@@ -1359,25 +1369,25 @@ msgstr "如何以相反的顺序迭代序列?"
13591369#: ../../faq/programming.rst:1142
13601370msgid ""
13611371"Use the :func:`reversed` built-in function, which is new in Python 2.4::"
1362- msgstr ""
1372+ msgstr "使用 :func:`reversed` 内置函数,这是Python 2.4中的新功能:: "
13631373
13641374#: ../../faq/programming.rst:1147
13651375msgid ""
13661376"This won't touch your original sequence, but build a new copy with reversed "
13671377"order to iterate over."
1368- msgstr ""
1378+ msgstr "这不会修改您的原始序列,而是构建一个反向顺序的新副本以进行迭代。 "
13691379
13701380#: ../../faq/programming.rst:1150
13711381msgid "With Python 2.3, you can use an extended slice syntax::"
1372- msgstr ""
1382+ msgstr "在 Python 2.3 里,您可以使用扩展切片语法:: "
13731383
13741384#: ../../faq/programming.rst:1157
13751385msgid "How do you remove duplicates from a list?"
13761386msgstr "如何从列表中删除重复项?"
13771387
13781388#: ../../faq/programming.rst:1159
13791389msgid "See the Python Cookbook for a long discussion of many ways to do this:"
1380- msgstr ""
1390+ msgstr "有关执行此操作的许多方法的详细讨论,请参阅 Python Cookbook: "
13811391
13821392#: ../../faq/programming.rst:1161
13831393msgid "https://code.activestate.com/recipes/52560/"
@@ -1387,19 +1397,19 @@ msgstr "https://code.activestate.com/recipes/52560/"
13871397msgid ""
13881398"If you don't mind reordering the list, sort it and then scan from the end of"
13891399" the list, deleting duplicates as you go::"
1390- msgstr ""
1400+ msgstr "如果您不介意重新排序列表,请对其进行排序,然后从列表末尾进行扫描,删除重复项: "
13911401
13921402#: ../../faq/programming.rst:1175
13931403msgid ""
13941404"If all elements of the list may be used as set keys (i.e. they are all "
13951405":term:`hashable`) this is often faster ::"
1396- msgstr ""
1406+ msgstr "如果列表的所有元素都可以用作设置键(即:它们都是 :term:`hashable` ),这通常会更快:: "
13971407
13981408#: ../../faq/programming.rst:1180
13991409msgid ""
14001410"This converts the list into a set, thereby removing duplicates, and then "
14011411"back into a list."
1402- msgstr ""
1412+ msgstr "这会将列表转换为集合,从而删除重复项,然后返回到列表中。 "
14031413
14041414#: ../../faq/programming.rst:1185
14051415msgid "How do you make an array in Python?"
0 commit comments