8
8
msgstr ""
9
9
"Project-Id-Version : Python 3.11\n "
10
10
"Report-Msgid-Bugs-To : \n "
11
- "POT-Creation-Date : 2022-10-15 20:43 +0000\n "
11
+ "POT-Creation-Date : 2023-04-25 00:20 +0000\n "
12
12
"PO-Revision-Date : 2018-05-23 14:36+0000\n "
13
13
"Last-Translator : Adrian Liaw <adrianliaw2000@gmail.com>\n "
14
14
"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
@@ -697,8 +697,8 @@ msgstr ""
697
697
msgid ""
698
698
"The descriptor protocol is simple and offers exciting possibilities. "
699
699
"Several use cases are so common that they have been prepackaged into built-"
700
- "in tools. Properties, bound methods, static methods, class methods, and \\ _ "
701
- "\\ _slots\\ _\\ _ are all based on the descriptor protocol."
700
+ "in tools. Properties, bound methods, static methods, class methods, and "
701
+ "\\ _ \\ _slots\\ _\\ _ are all based on the descriptor protocol."
702
702
msgstr ""
703
703
704
704
#: ../../howto/descriptor.rst:957
@@ -924,18 +924,26 @@ msgid ""
924
924
"`staticmethod` would look like this:"
925
925
msgstr ""
926
926
927
- #: ../../howto/descriptor.rst:1310
927
+ #: ../../howto/descriptor.rst:1291
928
+ msgid ""
929
+ "The :func:`functools.update_wrapper` call adds a ``__wrapped__`` attribute "
930
+ "that refers to the underlying function. Also it carries forward the "
931
+ "attributes necessary to make the wrapper look like the wrapped function: "
932
+ "``__name__``, ``__qualname__``, ``__doc__``, and ``__annotations__``."
933
+ msgstr ""
934
+
935
+ #: ../../howto/descriptor.rst:1359
928
936
msgid "Class methods"
929
937
msgstr ""
930
938
931
- #: ../../howto/descriptor.rst:1312
939
+ #: ../../howto/descriptor.rst:1361
932
940
msgid ""
933
941
"Unlike static methods, class methods prepend the class reference to the "
934
942
"argument list before calling the function. This format is the same for "
935
943
"whether the caller is an object or a class:"
936
944
msgstr ""
937
945
938
- #: ../../howto/descriptor.rst:1330
946
+ #: ../../howto/descriptor.rst:1379
939
947
msgid ""
940
948
"This behavior is useful whenever the method only needs to have a class "
941
949
"reference and does not rely on data stored in a specific instance. One use "
@@ -944,68 +952,77 @@ msgid ""
944
952
"of keys. The pure Python equivalent is:"
945
953
msgstr ""
946
954
947
- #: ../../howto/descriptor.rst:1347
955
+ #: ../../howto/descriptor.rst:1396
948
956
msgid "Now a new dictionary of unique keys can be constructed like this:"
949
957
msgstr ""
950
958
951
- #: ../../howto/descriptor.rst:1357
959
+ #: ../../howto/descriptor.rst:1406
952
960
msgid ""
953
961
"Using the non-data descriptor protocol, a pure Python version of :func:"
954
962
"`classmethod` would look like this:"
955
963
msgstr ""
956
964
957
- #: ../../howto/descriptor.rst:1408
965
+ #: ../../howto/descriptor.rst:1484
958
966
msgid ""
959
967
"The code path for ``hasattr(type(self.f), '__get__')`` was added in Python "
960
968
"3.9 and makes it possible for :func:`classmethod` to support chained "
961
969
"decorators. For example, a classmethod and property could be chained "
962
970
"together. In Python 3.11, this functionality was deprecated."
963
971
msgstr ""
964
972
965
- #: ../../howto/descriptor.rst:1428
973
+ #: ../../howto/descriptor.rst:1502
974
+ msgid ""
975
+ "The :func:`functools.update_wrapper` call in ``ClassMethod`` adds a "
976
+ "``__wrapped__`` attribute that refers to the underlying function. Also it "
977
+ "carries forward the attributes necessary to make the wrapper look like the "
978
+ "wrapped function: ``__name__``, ``__qualname__``, ``__doc__``, and "
979
+ "``__annotations__``."
980
+ msgstr ""
981
+
982
+ #: ../../howto/descriptor.rst:1510
966
983
msgid "Member objects and __slots__"
967
984
msgstr ""
968
985
969
- #: ../../howto/descriptor.rst:1430
986
+ #: ../../howto/descriptor.rst:1512
970
987
msgid ""
971
988
"When a class defines ``__slots__``, it replaces instance dictionaries with a "
972
989
"fixed-length array of slot values. From a user point of view that has "
973
990
"several effects:"
974
991
msgstr ""
975
992
976
- #: ../../howto/descriptor.rst:1434
993
+ #: ../../howto/descriptor.rst:1516
977
994
msgid ""
978
995
"1. Provides immediate detection of bugs due to misspelled attribute "
979
996
"assignments. Only attribute names specified in ``__slots__`` are allowed:"
980
997
msgstr ""
981
998
982
- #: ../../howto/descriptor.rst:1450
999
+ #: ../../howto/descriptor.rst:1532
983
1000
msgid ""
984
1001
"2. Helps create immutable objects where descriptors manage access to private "
985
1002
"attributes stored in ``__slots__``:"
986
1003
msgstr ""
987
1004
988
- #: ../../howto/descriptor.rst:1485
1005
+ #: ../../howto/descriptor.rst:1567
989
1006
msgid ""
990
1007
"3. Saves memory. On a 64-bit Linux build, an instance with two attributes "
991
1008
"takes 48 bytes with ``__slots__`` and 152 bytes without. This `flyweight "
992
1009
"design pattern <https://en.wikipedia.org/wiki/Flyweight_pattern>`_ likely "
993
1010
"only matters when a large number of instances are going to be created."
994
1011
msgstr ""
995
1012
996
- #: ../../howto/descriptor.rst:1490
1013
+ #: ../../howto/descriptor.rst:1572
997
1014
msgid ""
998
1015
"4. Improves speed. Reading instance variables is 35% faster with "
999
1016
"``__slots__`` (as measured with Python 3.10 on an Apple M1 processor)."
1000
1017
msgstr ""
1001
1018
1002
- #: ../../howto/descriptor.rst:1493
1019
+ #: ../../howto/descriptor.rst:1575
1003
1020
msgid ""
1004
1021
"5. Blocks tools like :func:`functools.cached_property` which require an "
1005
1022
"instance dictionary to function correctly:"
1006
1023
msgstr ""
1007
1024
1008
- #: ../../howto/descriptor.rst:1515
1025
+ #: ../../howto/descriptor.rst:1597
1009
1026
msgid ""
1010
1027
"It is not possible to create an exact drop-in pure Python version of "
1011
1028
"``__slots__`` because it requires direct access to C structures and control "
@@ -1015,36 +1032,36 @@ msgid ""
1015
1032
"managed by member descriptors:"
1016
1033
msgstr ""
1017
1034
1018
- #: ../../howto/descriptor.rst:1560
1035
+ #: ../../howto/descriptor.rst:1642
1019
1036
msgid ""
1020
1037
"The :meth:`type.__new__` method takes care of adding member objects to class "
1021
1038
"variables:"
1022
1039
msgstr ""
1023
1040
1024
- #: ../../howto/descriptor.rst:1576
1041
+ #: ../../howto/descriptor.rst:1658
1025
1042
msgid ""
1026
1043
"The :meth:`object.__new__` method takes care of creating instances that have "
1027
1044
"slots instead of an instance dictionary. Here is a rough simulation in pure "
1028
1045
"Python:"
1029
1046
msgstr ""
1030
1047
1031
- #: ../../howto/descriptor.rst:1611
1048
+ #: ../../howto/descriptor.rst:1693
1032
1049
msgid ""
1033
1050
"To use the simulation in a real class, just inherit from :class:`Object` and "
1034
1051
"set the :term:`metaclass` to :class:`Type`:"
1035
1052
msgstr ""
1036
1053
1037
- #: ../../howto/descriptor.rst:1625
1054
+ #: ../../howto/descriptor.rst:1707
1038
1055
msgid ""
1039
1056
"At this point, the metaclass has loaded member objects for *x* and *y*::"
1040
1057
msgstr ""
1041
1058
1042
- #: ../../howto/descriptor.rst:1646
1059
+ #: ../../howto/descriptor.rst:1728
1043
1060
msgid ""
1044
1061
"When instances are created, they have a ``slot_values`` list where the "
1045
1062
"attributes are stored:"
1046
1063
msgstr ""
1047
1064
1048
- #: ../../howto/descriptor.rst:1658
1065
+ #: ../../howto/descriptor.rst:1740
1049
1066
msgid "Misspelled or unassigned attributes will raise an exception:"
1050
1067
msgstr ""
0 commit comments