@@ -320,7 +320,7 @@ msgstr ""
320320msgid ""
321321"Why does Python use methods for some functionality (e.g. list.index()) but "
322322"functions for other (e.g. len(list))?"
323- msgstr "为什么Python对某些功能( 例如list.index()使用方法来实现,而其他功能( 例如len(List)使用函数实现?"
323+ msgstr "为什么Python对某些功能( 例如list.index()) 使用方法来实现,而其他功能( 例如len(List)) 使用函数实现?"
324324
325325#: ../../faq/design.rst:218
326326msgid "As Guido said:"
@@ -563,9 +563,9 @@ msgid ""
563563"provides functions to perform a garbage collection, obtain debugging "
564564"statistics, and tune the collector's parameters."
565565msgstr ""
566- "Python内存管理的细节取决于实现。Python的标准实现 "
567- ":term:`CPython` 使用引用计数来检测不可访问的对象,并使用另一种机制来收集引用循环,定期执行循环检测算法来查找不可访问的循环并删除所涉及的对象。"
568- " :mod:`gc` 模块提供了执行垃圾收集 、获取调试统计信息和优化收集器参数的函数"
566+ "Python内存管理的细节取决于实现。Python的标准实现 :term:`CPython` "
567+ "使用引用计数来检测不可访问的对象,并使用另一种机制来收集引用循环,定期执行循环检测算法来查找不可访问的循环并删除所涉及的对象。 :mod:`gc` "
568+ "模模块块提供了执行垃圾收集 、获取调试统计信息和优化收集器参数的函数"
569569
570570#: ../../faq/design.rst:393
571571msgid ""
@@ -643,12 +643,14 @@ msgid ""
643643"complain about these). Python is, however, aggressive about cleaning up "
644644"memory on exit and does try to destroy every single object."
645645msgstr ""
646+ "当Python退出时,从全局命名空间或Python模块引用的对象并不总是被释放。 如果存在循环引用,则可能发生这种情况 "
647+ "C库分配的某些内存也是不可能释放的(例如像Purify这样的工具会抱怨这些内容)。 但是,Python在退出时清理内存并尝试销毁每个对象。"
646648
647649#: ../../faq/design.rst:447
648650msgid ""
649651"If you want to force Python to delete certain things on deallocation use the"
650652" :mod:`atexit` module to run a function that will force those deletions."
651- msgstr ""
653+ msgstr "如果要强制python在释放时删除某些内容,请使用:mod: ' atexit '模块运行一个函数,强制删除这些内容。 "
652654
653655#: ../../faq/design.rst:452
654656msgid "Why are there separate tuple and list data types?"
@@ -663,6 +665,7 @@ msgid ""
663665" Cartesian coordinate is appropriately represented as a tuple of two or "
664666"three numbers."
665667msgstr ""
668+ "虽然列表和元组在许多方面是相似的,但它们的使用方式通常是完全不同的。可以认为元组类似于Pascal记录或C结构;它们是相关数据的小集合,可以是不同类型的数据,可以作为一个组进行操作。例如,笛卡尔坐标适当地表示为两个或三个数字的元组。"
666669
667670#: ../../faq/design.rst:461
668671msgid ""
@@ -673,6 +676,8 @@ msgid ""
673676"Functions which operate on this output would generally not break if you "
674677"added another file or two to the directory."
675678msgstr ""
679+ "另一方面,列表更像其他语言中的数组。它们倾向于持有不同数量的对象,所有对象都具有相同的类型,并且逐个操作。例如,``os.listdir('.')`` "
680+ "返回表示当前目录中的文件的字符串列表。如果向目录中添加了一两个文件,对此输出进行操作的函数通常不会中断。"
676681
677682#: ../../faq/design.rst:468
678683msgid ""
@@ -682,6 +687,7 @@ msgid ""
682687"be used as dictionary keys, and hence only tuples and not lists can be used "
683688"as keys."
684689msgstr ""
690+ "元组是不可变的,这意味着一旦创建了元组,就不能用新值替换它的任何元素。列表是可变的,这意味着您始终可以更改列表的元素。只有不变元素可以用作字典的key,因此只能将元组和非列表用作key。"
685691
686692#: ../../faq/design.rst:475
687693msgid "How are lists implemented in CPython?"
@@ -694,12 +700,13 @@ msgid ""
694700"objects, and keeps a pointer to this array and the array's length in a list "
695701"head structure."
696702msgstr ""
703+ "CPython的列表实际上是可变长度的数组,而不是lisp风格的链表。该实现使用对其他对象的引用的连续数组,并在列表头结构中保留指向该数组和数组长度的指针。"
697704
698705#: ../../faq/design.rst:481
699706msgid ""
700707"This makes indexing a list ``a[i]`` an operation whose cost is independent "
701708"of the size of the list or the value of the index."
702- msgstr ""
709+ msgstr "这使得索引列表``a[i]``的操作成本与列表的大小或索引的值无关。 "
703710
704711#: ../../faq/design.rst:484
705712msgid ""
@@ -708,6 +715,8 @@ msgid ""
708715"repeatedly; when the array must be grown, some extra space is allocated so "
709716"the next few times don't require an actual resize."
710717msgstr ""
718+ "当添加或插入项时,将调整引用数组的大小。并采用了一些巧妙的方法来提高重复添加项的性能; "
719+ "当数组必须增长时,会分配一些额外的空间,以便在接下来的几次中不需要实际调整大小。"
711720
712721#: ../../faq/design.rst:491
713722msgid "How are dictionaries implemented in CPython?"
@@ -719,7 +728,7 @@ msgid ""
719728"to B-trees, this gives better performance for lookup (the most common "
720729"operation by far) under most circumstances, and the implementation is "
721730"simpler."
722- msgstr ""
731+ msgstr "CPython的字典实现为可调整大小的哈希表。与B-树相比,这在大多数情况下为查找(目前最常见的操作)提供了更好的性能,并且实现更简单。 "
723732
724733#: ../../faq/design.rst:497
725734msgid ""
@@ -733,6 +742,10 @@ msgid ""
733742"dictionaries take constant time -- O(1), in Big-O notation -- to retrieve a "
734743"key."
735744msgstr ""
745+ "字典的工作方式是使用 :func:`hash` "
746+ "内置函数计算字典中存储的每个键的hash代码。hash代码根据键和每个进程的种子而变化很大;例如,\" Python\" "
747+ "的hash值为-539294296,而\" python\" (一个按位不同的字符串)的hash值为1142331976。然后,hash代码用于计算内部数组中将存储该值的位置。假设您存储的键都具有不同的hash值,这意味着字典需要恒定的时间"
748+ " -- O(1),用Big-O表示法 -- 来检索一个键。"
736749
737750#: ../../faq/design.rst:508
738751msgid "Why must dictionary keys be immutable?"
0 commit comments