7
7
msgstr ""
8
8
"Project-Id-Version : Python 3.13\n "
9
9
"Report-Msgid-Bugs-To : \n "
10
- "POT-Creation-Date : 2025-08-18 00:18 +0000\n "
10
+ "POT-Creation-Date : 2025-08-27 00:15 +0000\n "
11
11
"PO-Revision-Date : 2023-04-24 20:49+0800\n "
12
12
"
Last-Translator :
Adrian Liaw <[email protected] >\n "
13
13
"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
@@ -2874,23 +2874,33 @@ msgstr ""
2874
2874
2875
2875
#: ../../c-api/init.rst:2399
2876
2876
msgid ""
2877
- "Critical sections avoid deadlocks by implicitly suspending active critical "
2878
- "sections and releasing the locks during calls to :c:func:"
2879
- "`PyEval_SaveThread`. When :c:func:`PyEval_RestoreThread` is called, the most "
2880
- "recent critical section is resumed, and its locks reacquired. This means "
2881
- "the critical section API provides weaker guarantees than traditional locks "
2882
- "-- they are useful because their behavior is similar to the :term:`GIL`."
2877
+ "Critical sections are intended to be used for custom types implemented in C-"
2878
+ "API extensions. They should generally not be used with built-in types like :"
2879
+ "class:`list` and :class:`dict` because their public C-APIs already use "
2880
+ "critical sections internally, with the notable exception of :c:func:"
2881
+ "`PyDict_Next`, which requires critical section to be acquired externally."
2883
2882
msgstr ""
2884
2883
2885
2884
#: ../../c-api/init.rst:2406
2886
2885
msgid ""
2886
+ "Critical sections avoid deadlocks by implicitly suspending active critical "
2887
+ "sections, hence, they do not provide exclusive access such as provided by "
2888
+ "traditional locks like :c:type:`PyMutex`. When a critical section is "
2889
+ "started, the per-object lock for the object is acquired. If the code "
2890
+ "executed inside the critical section calls C-API functions then it can "
2891
+ "suspend the critical section thereby releasing the per-object lock, so other "
2892
+ "threads can acquire the per-object lock for the same object."
2893
+ msgstr ""
2894
+
2895
+ #: ../../c-api/init.rst:2414
2896
+ msgid ""
2887
2897
"The functions and structs used by the macros are exposed for cases where C "
2888
2898
"macros are not available. They should only be used as in the given macro "
2889
2899
"expansions. Note that the sizes and contents of the structures may change in "
2890
2900
"future Python versions."
2891
2901
msgstr ""
2892
2902
2893
- #: ../../c-api/init.rst:2413
2903
+ #: ../../c-api/init.rst:2421
2894
2904
msgid ""
2895
2905
"Operations that need to lock two objects at once must use :c:macro:"
2896
2906
"`Py_BEGIN_CRITICAL_SECTION2`. You *cannot* use nested critical sections to "
@@ -2899,11 +2909,11 @@ msgid ""
2899
2909
"lock more than two objects at once."
2900
2910
msgstr ""
2901
2911
2902
- #: ../../c-api/init.rst:2419
2912
+ #: ../../c-api/init.rst:2427
2903
2913
msgid "Example usage::"
2904
2914
msgstr "範例用法: ::"
2905
2915
2906
- #: ../../c-api/init.rst:2421
2916
+ #: ../../c-api/init.rst:2429
2907
2917
msgid ""
2908
2918
"static PyObject *\n"
2909
2919
"set_field(MyObject *self, PyObject *value)\n"
@@ -2923,7 +2933,7 @@ msgstr ""
2923
2933
" Py_RETURN_NONE;\n"
2924
2934
"}"
2925
2935
2926
- #: ../../c-api/init.rst:2430
2936
+ #: ../../c-api/init.rst:2438
2927
2937
msgid ""
2928
2938
"In the above example, :c:macro:`Py_SETREF` calls :c:macro:`Py_DECREF`, which "
2929
2939
"can call arbitrary code through an object's deallocation function. The "
@@ -2933,18 +2943,18 @@ msgid ""
2933
2943
"`PyEval_SaveThread`."
2934
2944
msgstr ""
2935
2945
2936
- #: ../../c-api/init.rst:2438
2946
+ #: ../../c-api/init.rst:2446
2937
2947
msgid ""
2938
2948
"Acquires the per-object lock for the object *op* and begins a critical "
2939
2949
"section."
2940
2950
msgstr ""
2941
2951
2942
- #: ../../c-api/init.rst:2441 ../../c-api/init.rst:2455
2943
- #: ../../c-api/init.rst:2470 ../../c-api/init.rst:2484
2952
+ #: ../../c-api/init.rst:2449 ../../c-api/init.rst:2463
2953
+ #: ../../c-api/init.rst:2478 ../../c-api/init.rst:2492
2944
2954
msgid "In the free-threaded build, this macro expands to::"
2945
2955
msgstr ""
2946
2956
2947
- #: ../../c-api/init.rst:2443
2957
+ #: ../../c-api/init.rst:2451
2948
2958
msgid ""
2949
2959
"{\n"
2950
2960
" PyCriticalSection _py_cs;\n"
@@ -2954,34 +2964,34 @@ msgstr ""
2954
2964
" PyCriticalSection _py_cs;\n"
2955
2965
" PyCriticalSection_Begin(&_py_cs, (PyObject*)(op))"
2956
2966
2957
- #: ../../c-api/init.rst:2447 ../../c-api/init.rst:2476
2967
+ #: ../../c-api/init.rst:2455 ../../c-api/init.rst:2484
2958
2968
msgid "In the default build, this macro expands to ``{``."
2959
2969
msgstr ""
2960
2970
2961
- #: ../../c-api/init.rst:2453
2971
+ #: ../../c-api/init.rst:2461
2962
2972
msgid "Ends the critical section and releases the per-object lock."
2963
2973
msgstr ""
2964
2974
2965
- #: ../../c-api/init.rst:2457
2975
+ #: ../../c-api/init.rst:2465
2966
2976
msgid ""
2967
2977
" PyCriticalSection_End(&_py_cs);\n"
2968
2978
"}"
2969
2979
msgstr ""
2970
2980
" PyCriticalSection_End(&_py_cs);\n"
2971
2981
"}"
2972
2982
2973
- #: ../../c-api/init.rst:2460 ../../c-api/init.rst:2489
2983
+ #: ../../c-api/init.rst:2468 ../../c-api/init.rst:2497
2974
2984
msgid "In the default build, this macro expands to ``}``."
2975
2985
msgstr ""
2976
2986
2977
- #: ../../c-api/init.rst:2466
2987
+ #: ../../c-api/init.rst:2474
2978
2988
msgid ""
2979
2989
"Acquires the per-objects locks for the objects *a* and *b* and begins a "
2980
2990
"critical section. The locks are acquired in a consistent order (lowest "
2981
2991
"address first) to avoid lock ordering deadlocks."
2982
2992
msgstr ""
2983
2993
2984
- #: ../../c-api/init.rst:2472
2994
+ #: ../../c-api/init.rst:2480
2985
2995
msgid ""
2986
2996
"{\n"
2987
2997
" PyCriticalSection2 _py_cs2;\n"
@@ -2991,11 +3001,11 @@ msgstr ""
2991
3001
" PyCriticalSection2 _py_cs2;\n"
2992
3002
" PyCriticalSection2_Begin(&_py_cs2, (PyObject*)(a), (PyObject*)(b))"
2993
3003
2994
- #: ../../c-api/init.rst:2482
3004
+ #: ../../c-api/init.rst:2490
2995
3005
msgid "Ends the critical section and releases the per-object locks."
2996
3006
msgstr ""
2997
3007
2998
- #: ../../c-api/init.rst:2486
3008
+ #: ../../c-api/init.rst:2494
2999
3009
msgid ""
3000
3010
" PyCriticalSection2_End(&_py_cs2);\n"
3001
3011
"}"
0 commit comments