@@ -564,6 +564,8 @@ msgid ""
564
564
"Perl, and PHP also support them. The augmented assignment patch was "
565
565
"implemented by Thomas Wouters."
566
566
msgstr ""
567
+ "增强赋值运算符最早在 C 编程语言中引入,大多数 C 派生语言,如 :program:`awk`,C++,Java 和 PHP 也支持它们。 "
568
+ "增强赋值补丁由 Thomas Wouters 实现。"
567
569
568
570
#: ../../whatsnew/2.0.rst:390
569
571
msgid "String Methods"
@@ -585,7 +587,7 @@ msgid ""
585
587
"Instead, Python 2.0 pushes the problem onto the string type, making string "
586
588
"manipulation functionality available through methods on both 8-bit strings "
587
589
"and Unicode strings. ::"
588
- msgstr ""
590
+ msgstr "相反,Python 2.0 将这个问题推给了字符串类型,使字符串操作功能通过 8 位字符串和 Unicode 字符串上的方法来实现。 "
589
591
590
592
#: ../../whatsnew/2.0.rst:411
591
593
msgid ""
@@ -594,12 +596,13 @@ msgid ""
594
596
"methods return new strings, and do not modify the string on which they "
595
597
"operate."
596
598
msgstr ""
599
+ "有一件事没有改变,即使是值得注意的愚人节玩笑,Python 字符串仍然是不可变的。 因此,字符串方法返回的是新的字符串,而不是修改他们操作的原字符串。"
597
600
598
601
#: ../../whatsnew/2.0.rst:415
599
602
msgid ""
600
603
"The old :mod:`string` module is still around for backwards compatibility, "
601
604
"but it mostly acts as a front-end to the new string methods."
602
- msgstr ""
605
+ msgstr "旧的 :mod:`string` 模块仍然存在以保持向向兼容,但它主要作为新字符串方法的前端。 "
603
606
604
607
#: ../../whatsnew/2.0.rst:418
605
608
msgid ""
@@ -631,6 +634,8 @@ msgid ""
631
634
"no longer accessible, since you need to have a reference to an object to "
632
635
"access it, and if the count is zero, no references exist any longer."
633
636
msgstr ""
637
+ "Python 的 C 实现使用引用技术来实现垃圾回收。 每个 Python 对象维护一个指向自身的引用数量,并在引用创建或销毁时调整该计数。 "
638
+ "一旦引用计数达到零,对象就不再可访问,因为访问对象需要一个引用,然后如果计数为零,就不再存在任何引用。"
634
639
635
640
#: ../../whatsnew/2.0.rst:442
636
641
msgid ""
@@ -641,19 +646,22 @@ msgid ""
641
646
"doesn't realise that objects are no longer accessible, resulting in a memory"
642
647
" leak. This happens when there are cycles of references."
643
648
msgstr ""
649
+ "引用计数有一些令人愉快的特性:它易于理解和实现,结果实现是可移植的,相当快,并且与其他实现自己内存处理方案的库良好互动。引用计数的主要问题是有时它无法识别对象不再可访问,从而导致内存泄露,这发生在存在引用循环时。"
644
650
645
651
#: ../../whatsnew/2.0.rst:449
646
652
msgid ""
647
653
"Consider the simplest possible cycle, a class instance which has a "
648
654
"reference to itself::"
649
- msgstr ""
655
+ msgstr "考虑最简单的循环,一个类实例引用自身:: "
650
656
651
657
#: ../../whatsnew/2.0.rst:455
652
658
msgid ""
653
659
"After the above two lines of code have been executed, the reference count of"
654
660
" ``instance`` is 2; one reference is from the variable named ``'instance'``,"
655
661
" and the other is from the ``myself`` attribute of the instance."
656
662
msgstr ""
663
+ "在执行完上述两行代码后,``instance`` 的引用计数是 2;一个引用来自名为 ``'instance'`` 的变量,另一个引用来自该实例的 "
664
+ "``myself`` 属性。"
657
665
658
666
#: ../../whatsnew/2.0.rst:459
659
667
msgid ""
@@ -664,6 +672,9 @@ msgid ""
664
672
" objects can participate in a cycle if they have references to each other, "
665
673
"causing all of the objects to be leaked."
666
674
msgstr ""
675
+ "如果下一行代码是 ``del instance``,会发生什么? ``instance`` 的引用计数会减少 1,所以它的引用计数变为 "
676
+ "1;``myself`` 属性中的引用仍然存在。 然而,该实例不能再通过 Python 代码访问,并且它可以被删除。 "
677
+ "如果多个对象相互引用,它们可以参与一个循环,导致所有对象都无法被垃圾回收,从而导致内存泄漏。"
667
678
668
679
#: ../../whatsnew/2.0.rst:466
669
680
msgid ""
@@ -673,6 +684,8 @@ msgid ""
673
684
"collection, obtain debugging statistics, and tuning the collector's "
674
685
"parameters."
675
686
msgstr ""
687
+ "Python 2.0 通过周期性的执行一个循环检测算法来解决这个问题,该算法查找不可访问的循环并删除涉及的对象。 一个新的 :mod:`gc` "
688
+ "模块提供了执行垃圾回收、获取调试统计信息和调整回收器参数的功能。"
676
689
677
690
#: ../../whatsnew/2.0.rst:471
678
691
msgid ""
@@ -687,6 +700,10 @@ msgid ""
687
700
"buggy, by specifying the :option:`!--without-cycle-gc` switch when running "
688
701
"the :program:`configure` script."
689
702
msgstr ""
703
+ "运行循环检测算法需要一些时间,因此会带来一些额外的开销,希望在使用 2.0 版本的循环收集经验之后,Python 2.1 "
704
+ "可以通过精细调整来尽量减少开销。 目前还不清楚性能损失有多大,因为对此进行精准测试很棘手,而且关键在于程序创建和销毁对象的频率。 "
705
+ "如果你不能接受哪怕是微小的速度损失,或者怀疑循环收集存在问题,可以在编译 Python 时禁用循环检测,通过在运行 "
706
+ ":program:`configure` 脚本时指定 :option:`!--without-cycle-gc` 开关来实现。"
690
707
691
708
#: ../../whatsnew/2.0.rst:482
692
709
msgid ""
@@ -700,6 +717,10 @@ msgid ""
700
717
"threads titled \" Reference cycle collection for Python\" and \" Finalization "
701
718
"again\" ."
702
719
msgstr ""
720
+ "有几个人解决了这个问题并为解决方案做出了贡献。循环检测方法的早期实现由 Toby Kelsey 编写。 当前的算法是在 Eric Tiedemann "
721
+ "访问 CNRI 期间提出的,Guido van Rossum 和 Neil Schemenauer 分别编写了两个不同的实现,后来由 Neil "
722
+ "将它们整合。 许多其他人也在过程中提出了建议;python-dev 邮件列表 2000 年 3 月的存档包含了大部分相关讨论,尤其是在标题为 "
723
+ "“Reference cycle collection for Python” 和 “Finalization again” 的帖子中。"
703
724
704
725
#: ../../whatsnew/2.0.rst:495
705
726
msgid "Other Core Changes"
@@ -710,7 +731,7 @@ msgid ""
710
731
"Various minor changes have been made to Python's syntax and built-in "
711
732
"functions. None of the changes are very far-reaching, but they're handy "
712
733
"conveniences."
713
- msgstr ""
734
+ msgstr "Python 的语法和内置函数进行了各种小改动。 虽然这些改动都不是非常深远,但它们都是很方便的改进。 "
714
735
715
736
#: ../../whatsnew/2.0.rst:502
716
737
msgid "Minor Language Changes"
@@ -745,6 +766,8 @@ msgid ""
745
766
"module as name`` or ``from module import name as othername``. The patch was"
746
767
" submitted by Thomas Wouters."
747
768
msgstr ""
769
+ "模块现在可以在导入时重命名,使用语法 ``import module as name`` 或 ``from module import name as "
770
+ "othername``。这个补丁是由 Thomas Wouters 提交的。"
748
771
749
772
#: ../../whatsnew/2.0.rst:532
750
773
msgid ""
@@ -754,6 +777,9 @@ msgid ""
754
777
"which inserts the :func:`str` of its argument. For example, ``'%r %s' % "
755
778
"('abc', 'abc')`` returns a string containing ``'abc' abc``."
756
779
msgstr ""
780
+ "当使用 ``%`` 操作符时有一种新的格式样式可用;'%r' 将插入其参数的 :func:`repr` 表示。 这也是为了对称性,这次是为了与现有的 "
781
+ "%s 格式样式对称,后者插入其参数的 :func:`str` 表示。例如,``'%r %s' % ('abc', 'abc')`` 返回一个包含 "
782
+ "``'abc' abc`` 的字符串。"
757
783
758
784
#: ../../whatsnew/2.0.rst:538
759
785
msgid ""
@@ -777,6 +803,9 @@ msgid ""
777
803
" and crashed; Jeremy Hylton rewrote the code to no longer crash, producing a"
778
804
" useful result instead. For example, after this code::"
779
805
msgstr ""
806
+ "早期版本的 Python 使用递归算法来删除对象。深度嵌套的数据结构可能导致解释器填满 C 栈并崩溃。 Christian Tismer "
807
+ "重写了删除逻辑来解决这个问题。 相关地,比较递归对象时会导致无线递归并崩溃。Jeremy Hylton 重写了代码,使其不再崩溃,而是产生有用的结果。 "
808
+ "例如,在以下代码之后::"
780
809
781
810
#: ../../whatsnew/2.0.rst:559
782
811
msgid ""
@@ -807,6 +836,8 @@ msgid ""
807
836
"suffix=.x\" . Consult the README in the Python source distribution for more "
808
837
"instructions."
809
838
msgstr ""
839
+ "另一个新的平台是 Darwin/MacOS X;Python 2.0 中提供了初步支持。如果你指定 \" configure --with-dyld "
840
+ "--with-suffix=.x\" ,动态加载是可行的。 有关更多说明,请参阅 Python 源代码分发中的 README 文件。"
810
841
811
842
#: ../../whatsnew/2.0.rst:581
812
843
msgid ""
@@ -819,6 +850,11 @@ msgid ""
819
850
"of :exc:`NameError`, so any existing code that expects :exc:`NameError` to "
820
851
"be raised should still work. ::"
821
852
msgstr ""
853
+ "已经尝试解决 Python 的一个问题,即当代码在局部变量赋值之前引用该变量时,会引发经常令人困惑的 :exc:`NameError` "
854
+ "异常。例如,以下代码在 1.5.2 和 2.0 中都会在 ``print`` 语句上引发异常;在 1.5.2 中,会引发 "
855
+ ":exc:`NameError` 异常,而在 2.0 中,会引发一个新的 :exc:`UnboundLocalError` 异常。 "
856
+ ":exc:`UnboundLocalError` 是 :exc:`NameError` 的子类,因此任何期望引发 :exc:`NameError` "
857
+ "的现有代码应该仍然可以正常工作。"
822
858
823
859
#: ../../whatsnew/2.0.rst:595
824
860
msgid ""
@@ -842,6 +878,10 @@ msgid ""
842
878
"``None`` if the sequences aren't all of the same length, while :func:`zip` "
843
879
"truncates the returned list to the length of the shortest argument sequence."
844
880
msgstr ""
881
+ "添加了一个新的内置函数 ``zip(seq1, seq2, ...)``。:func:`zip` "
882
+ "返回一个包含元组的列表,每个元组包含每个参数序列的第i个元素。:func:`zip` 和 ``map(None, seq1, seq2)`` "
883
+ "的区别在于,如果序列长度不一致,:func:`map` 会用 ``None`` 填充序列,而 :func:`zip` "
884
+ "会将返回的列表截短到最短的参数序列的长度。"
845
885
846
886
#: ../../whatsnew/2.0.rst:610
847
887
msgid ""
@@ -860,6 +900,10 @@ msgid ""
860
900
"``sys.version_info`` would be ``(2, 0, 1, 'beta', 1)``. *level* is a string "
861
901
"such as ``\" alpha\" ``, ``\" beta\" ``, or ``\" final\" `` for a final release."
862
902
msgstr ""
903
+ "在 :mod:`sys` 模块中添加了一个新变量,用于保存更详细的版本信息。 ``sys.version_info`` 是一个包含五个元素的元组 "
904
+ "``(major, minor, micro, level, serial)``。 例如,在假设的 2.0.1beta1 "
905
+ "版本中,``sys.version_info`` 将是 ``(2, 0, 1, 'beta', 1)``。 *level* 是一个字符串,如 "
906
+ "``\" alpha\" ``、``\" beta\" `` 或代表最终发布版本的 ``\" final\" ``。"
863
907
864
908
#: ../../whatsnew/2.0.rst:622
865
909
msgid ""
@@ -873,7 +917,7 @@ msgstr ""
873
917
#: ../../whatsnew/2.0.rst:633
874
918
msgid ""
875
919
"can be reduced to a single ``return dict.setdefault(key, [])`` statement."
876
- msgstr ""
920
+ msgstr "可以简化为单个``return dict.setdefault(key, [])``语句。 "
877
921
878
922
#: ../../whatsnew/2.0.rst:635
879
923
msgid ""
@@ -885,6 +929,10 @@ msgid ""
885
929
" value is 1000, and a rough maximum value for a given platform can be found "
886
930
"by running a new script, :file:`Misc/find_recursionlimit.py`."
887
931
msgstr ""
932
+ "解释器设置了一个最大递归深度,以便在填满 C 栈并导致核心储存或 GPF 之前捕获失控递归。以前这个限制是在编译 Python 时固定的,但在 2.0 "
933
+ "中最大递归深度可以使用 :func:`sys.getrecursionlimit` 和 :func:`sys.setrecursionlimit` "
934
+ "读取和修改。 默认值是 1000,可以通过运行一个新脚本 :file:`Misc/find_recursionlimit.py` "
935
+ "来找到给定平台的大致的最大值。"
888
936
889
937
#: ../../whatsnew/2.0.rst:647
890
938
msgid "Porting to 2.0"
@@ -899,6 +947,9 @@ msgid ""
899
947
"always be avoided. This section lists the changes in Python 2.0 that may "
900
948
"cause old Python code to break."
901
949
msgstr ""
950
+ "新的 Python 版本尽力与之前的版本兼容,而且兼容性记录相当不错。 "
951
+ "然而,有些变化被认为足够有用,通常是因为他们修正了最终设计中的错误决定,因此有时无法避免打破向后兼容性。 本节列出了 Python 2.0 中可能导致旧"
952
+ " Python 代码中断的更改。"
902
953
903
954
#: ../../whatsnew/2.0.rst:656
904
955
msgid ""
@@ -947,6 +998,8 @@ msgid ""
947
998
"the lowest 8 bits of the result, so ``\\ x123456`` was equivalent to "
948
999
"``\\ x56``."
949
1000
msgstr ""
1001
+ "字符串字面量中的 ``\\ x`` 转义现在必须精确地使用2个十六进制数字。之前它会消耗 x 后面的所有十六进制数字,并取结果的最低8位,所以 "
1002
+ "``\\ x123456`` 等同于 ``\\ x56``。"
950
1003
951
1004
#: ../../whatsnew/2.0.rst:688
952
1005
msgid ""
@@ -956,6 +1009,9 @@ msgid ""
956
1009
" error message was just the missing attribute name ``eggs``, and code "
957
1010
"written to take advantage of this fact will break in 2.0."
958
1011
msgstr ""
1012
+ ":exc:`AttributeError` 和 :exc:`NameError` 异常现在有了更友好的错误消息,其文本内容类似于 ``'Spam' "
1013
+ "instance has no attribute 'eggs'`` 或 ``name 'eggs' is not defined``。 "
1014
+ "之前的错误消息只是缺少的属性名称,如 ``eggs``,因此利用这一事实编写的代码在 2.0 中会中断。"
959
1015
960
1016
#: ../../whatsnew/2.0.rst:694
961
1017
msgid ""
@@ -984,6 +1040,9 @@ msgid ""
984
1040
" which does ``str(longval)[:-1]`` and assumes the 'L' is there, will now "
985
1041
"lose the final digit."
986
1042
msgstr ""
1043
+ "最微妙的长整数变化是,长整数的 :func:`str` 表示不再有尾随的 'L' 字符,尽管 :func:`repr` "
1044
+ "表示仍然包含它。许多人在打印长整数时不希望看到 'L' 字符,因为他们不得不专门去掉这个字符。在2.0中,这不再是一个问题,但那些使用 "
1045
+ "``str(longval)[:-1]`` 并假设存在 'L' 的代码,现在将丢失最后一个数字。"
987
1046
988
1047
#: ../../whatsnew/2.0.rst:716
989
1048
msgid ""
@@ -1016,6 +1075,8 @@ msgid ""
1016
1075
"larger application. If you aren't dealing with Python's C API, you can "
1017
1076
"safely skip this section."
1018
1077
msgstr ""
1078
+ "有些更改是在底层进行的,仅对编写 C 扩展模块或在更大的应用中嵌入 Python 解释器的人有价值。 如果你不处理 Python 的 C "
1079
+ "API,可以安全地跳过这一节。"
1019
1080
1020
1081
#: ../../whatsnew/2.0.rst:747
1021
1082
msgid ""
@@ -1025,6 +1086,9 @@ msgid ""
1025
1086
"built for Python 1.5.x due to how Windows DLLs work, so Python will raise an"
1026
1087
" exception and the import will fail."
1027
1088
msgstr ""
1089
+ " Python C API 的版本号已增加,因此为 1.5.2 编译的 C 扩展必须重新编译才能与 2.0 一起工作。 在 Windows 上,由于 "
1090
+ "Windows DLL 的工作方式,Python 2.0 无法导入为 Python 1.5.x 构建的第三方扩展,因此 Python "
1091
+ "会引发异常并造成导入失败。"
1028
1092
1029
1093
#: ../../whatsnew/2.0.rst:753
1030
1094
msgid ""
@@ -1034,6 +1098,10 @@ msgid ""
1034
1098
"remember to write code such as ``if type(obj) == myExtensionClass``, but can"
1035
1099
" use the more natural ``if isinstance(obj, myExtensionClass)``."
1036
1100
msgstr ""
1101
+ "使用 Jim Fulton 的 ExtensionClass 模块的用户将很高兴地发现,已经添加了钩子以支持 "
1102
+ "ExtensionClasses,因此现在支持 :func:`isinstance` 和 :func:`issubclass`。 "
1103
+ "这意味着你不再需要记住编写类似 ``if type(obj) == myExtensionClass`` 这样的代码,而可以使用更自然的 ``if "
1104
+ "isinstance(obj, myExtensionClass)``。"
1037
1105
1038
1106
#: ../../whatsnew/2.0.rst:759
1039
1107
msgid ""
@@ -1045,6 +1113,10 @@ msgid ""
1045
1113
"Include/ directory that held various portability hacks; they've been merged "
1046
1114
"into a single file, :file:`Include/pyport.h`."
1047
1115
msgstr ""
1116
+ ":file:`Python/importdl.c` 文件,它充满了用于支持在许多不同平台上动态加载的 #ifdef,已被 Greg Stein "
1117
+ "清理和重组。现在 :file:`importdl.c` 非常小,平台特定的代码已被移入一组特定的 "
1118
+ ":file:`Python/dynload_\\ *.c` 文件中。 另一个清理工作是:Include/ 目录中有许多包含各种可移植性修改的 "
1119
+ ":file:`my\\ *.h` 文件;它们已被合并到一个文件中,即 :file:`Include/pyport.h`。"
1048
1120
1049
1121
#: ../../whatsnew/2.0.rst:767
1050
1122
msgid ""
@@ -1063,6 +1135,8 @@ msgid ""
1063
1135
"Macintosh. Threading support using the user-space GNU ``pth`` library was "
1064
1136
"also contributed."
1065
1137
msgstr ""
1138
+ "最新版本的 MacOS GUSI 开发环境支持 POSIX 线程。 因此,现在 Python 的 POSIX 线程支持在 Macintosh "
1139
+ "上也可以使用。 还贡献了使用用户空间 GNU ``pth`` 库的线程支持。"
1066
1140
1067
1141
#: ../../whatsnew/2.0.rst:779
1068
1142
msgid ""
@@ -1073,13 +1147,18 @@ msgid ""
1073
1147
"slow as an unthreaded version; with the 2.0 changes, the difference is only "
1074
1148
"10%. These improvements were contributed by Yakov Markovitch."
1075
1149
msgstr ""
1150
+ "Windows 上的线程支持也得到了增强。 Windows "
1151
+ "支持的线程锁在发生争用时才使用内核对象;在常见的没有争用的情况下,他们使用简单得多的函数,这些函数快一个数量级。Python 1.5.2 在 NT "
1152
+ "上的线程版本比无线程版本慢两倍;有了 2.0 的改进,差异仅为 10%。 这些改进由 Yakov Markovitch 提供。"
1076
1153
1077
1154
#: ../../whatsnew/2.0.rst:786
1078
1155
msgid ""
1079
1156
"Python 2.0's source now uses only ANSI C prototypes, so compiling Python now"
1080
1157
" requires an ANSI C compiler, and can no longer be done using a compiler "
1081
1158
"that only supports K&R C."
1082
1159
msgstr ""
1160
+ "Python 2.0 的源代码目前只用 ANSI C 原型,所以现在编译 Python 需要一个 ANSI C 的编译器,而不能通过仅使用支持 K&R "
1161
+ "C 的编译器完成。"
1083
1162
1084
1163
#: ../../whatsnew/2.0.rst:790
1085
1164
msgid ""
@@ -1089,6 +1168,9 @@ msgid ""
1089
1168
"people who are generating Python code would run into this limit. A patch by"
1090
1169
" Charles G. Waldman raises the limit from ``2**16`` to ``2**32``."
1091
1170
msgstr ""
1171
+ "之前,Python 虚拟机在其字节码中使用 16 位数字,限制了源文件的大小。 特别是,这影响了 Python "
1172
+ "源代码中字面量列表和字典的最大大小;偶尔会有人在生成 Python 代码时遇到这个限制。 Charles G. Waldman 的补丁将这个限制从 "
1173
+ "``2**16`` 提高到 ``2**32``。"
1092
1174
1093
1175
#: ../../whatsnew/2.0.rst:796
1094
1176
msgid ""
@@ -1122,6 +1204,9 @@ msgid ""
1122
1204
"different extension packages, which made administering a Python installation"
1123
1205
" something of a chore."
1124
1206
msgstr ""
1207
+ "在 Python 2.0 之前,安装模块是一件繁琐的事情 —— 没有办法自动确定 Python 的安装位置,或者用于扩展模块的编译器选项。 "
1208
+ "软件作者不得不经历一套繁琐的程序来编辑 Makefile 和配置文件,这些只在 Unix 上真正有效,而 Windows 和 Mac OS 不受支持。 "
1209
+ "Python 用户面对不同扩展包之间大相径庭的安装说明,这使得管理 Python 成了一件麻烦事。"
1125
1210
1126
1211
#: ../../whatsnew/2.0.rst:821
1127
1212
msgid ""
@@ -1171,12 +1256,16 @@ msgid ""
1171
1256
"distribution formats such as Debian packages and Solaris :file:`.pkg` files "
1172
1257
"are in various stages of development."
1173
1258
msgstr ""
1259
+ "Distutils 还可以负责创建源代码和二进制分发包。运行 ``python setup.py sdist`` 的 \" sdist\" "
1260
+ "命令构建一个源代码分发包,如 :file:`foo-1.0.tar.gz`。添加新命令并不困难,已经有 \" bdist_rpm\" 和 "
1261
+ "\" bdist_wininst\" 命令,分别用于创建软件的 RPM 分发包和 Windows 安装程序。创建其他分发格式的命令,如 Debian 包和"
1262
+ " Solaris :file:`.pkg` 文件,也在开发的不同阶段。"
1174
1263
1175
1264
#: ../../whatsnew/2.0.rst:873
1176
1265
msgid ""
1177
1266
"All this is documented in a new manual, *Distributing Python Modules*, that "
1178
1267
"joins the basic set of Python documentation."
1179
- msgstr ""
1268
+ msgstr "所有这些都记录在一个新手册中,*Distributing Python Modules*,它加入了Python文档的基本集合中。 "
1180
1269
1181
1270
#: ../../whatsnew/2.0.rst:880
1182
1271
msgid "XML Modules"
@@ -1199,7 +1288,7 @@ msgstr ""
1199
1288
1200
1289
#: ../../whatsnew/2.0.rst:896
1201
1290
msgid "SAX2 Support"
1202
- msgstr ""
1291
+ msgstr "SAX2 支持 "
1203
1292
1204
1293
#: ../../whatsnew/2.0.rst:898
1205
1294
msgid ""
0 commit comments