-
-
Notifications
You must be signed in to change notification settings - Fork 211
/
Copy path3.12.po
5398 lines (4561 loc) · 195 KB
/
3.12.po
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright (C) 2001-2025, Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: Python 3.13\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-02-05 00:13+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
"tw)\n"
"Language: zh_TW\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: ../../whatsnew/3.12.rst:4
msgid "What's New In Python 3.12"
msgstr "Python 3.12 有什麼新功能"
#: ../../whatsnew/3.12.rst:0
msgid "Editor"
msgstr "編輯者"
#: ../../whatsnew/3.12.rst:6
msgid "Adam Turner"
msgstr "Adam Turner"
#: ../../whatsnew/3.12.rst:48
msgid ""
"This article explains the new features in Python 3.12, compared to 3.11. "
"Python 3.12 was released on October 2, 2023. For full details, see "
"the :ref:`changelog <changelog>`."
msgstr ""
"本文介紹了 Python 3.12 與 3.11 相比多了哪些新功能。 Python 3.12 於 2023 年 "
"10 月 2 日發布。完整詳情請見 :ref:`changelog <changelog>`。"
#: ../../whatsnew/3.12.rst:54
msgid ":pep:`693` -- Python 3.12 Release Schedule"
msgstr ":pep:`693` -- Python 3.12 發佈時程"
#: ../../whatsnew/3.12.rst:57
msgid "Summary -- Release highlights"
msgstr "發布重點摘要"
#: ../../whatsnew/3.12.rst:62
msgid ""
"Python 3.12 is a stable release of the Python programming language, with a "
"mix of changes to the language and the standard library. The library changes "
"focus on cleaning up deprecated APIs, usability, and correctness. Of note, "
"the :mod:`!distutils` package has been removed from the standard library. "
"Filesystem support in :mod:`os` and :mod:`pathlib` has seen a number of "
"improvements, and several modules have better performance."
msgstr ""
#: ../../whatsnew/3.12.rst:69
msgid ""
"The language changes focus on usability, as :term:`f-strings <f-string>` "
"have had many limitations removed and 'Did you mean ...' suggestions "
"continue to improve. The new :ref:`type parameter syntax <whatsnew312-"
"pep695>` and :keyword:`type` statement improve ergonomics for "
"using :term:`generic types <generic type>` and :term:`type aliases <type "
"alias>` with static type checkers."
msgstr ""
#: ../../whatsnew/3.12.rst:76
msgid ""
"This article doesn't attempt to provide a complete specification of all new "
"features, but instead gives a convenient overview. For full details, you "
"should refer to the documentation, such as the :ref:`Library Reference "
"<library-index>` and :ref:`Language Reference <reference-index>`. If you "
"want to understand the complete implementation and design rationale for a "
"change, refer to the PEP for a particular new feature; but note that PEPs "
"usually are not kept up-to-date once a feature has been fully implemented."
msgstr ""
#: ../../whatsnew/3.12.rst:90
msgid "New syntax features:"
msgstr "新增語法特性:"
#: ../../whatsnew/3.12.rst:92
msgid ""
":ref:`PEP 695 <whatsnew312-pep695>`, type parameter syntax and "
"the :keyword:`type` statement"
msgstr ""
":ref:`PEP 695 <whatsnew312-pep695>`,型別參數語法和 :keyword:`type` 陳述式"
#: ../../whatsnew/3.12.rst:94
msgid "New grammar features:"
msgstr "新增語法特性:"
#: ../../whatsnew/3.12.rst:96
msgid ""
":ref:`PEP 701 <whatsnew312-pep701>`, :term:`f-strings <f-string>` in the "
"grammar"
msgstr ""
#: ../../whatsnew/3.12.rst:98
msgid "Interpreter improvements:"
msgstr "直譯器改進:"
#: ../../whatsnew/3.12.rst:100
msgid ""
":ref:`PEP 684 <whatsnew312-pep684>`, a unique per-interpreter :term:`GIL "
"<global interpreter lock>`"
msgstr ""
#: ../../whatsnew/3.12.rst:102
msgid ":ref:`PEP 669 <whatsnew312-pep669>`, low impact monitoring"
msgstr ""
#: ../../whatsnew/3.12.rst:103
msgid ""
"`Improved 'Did you mean ...' suggestions <improved error messages_>`_ "
"for :exc:`NameError`, :exc:`ImportError`, and :exc:`SyntaxError` exceptions"
msgstr ""
#: ../../whatsnew/3.12.rst:106
msgid "Python data model improvements:"
msgstr "Python 資料模型改進:"
#: ../../whatsnew/3.12.rst:108
msgid ""
":ref:`PEP 688 <whatsnew312-pep688>`, using the :ref:`buffer protocol "
"<bufferobjects>` from Python"
msgstr ""
#: ../../whatsnew/3.12.rst:111
msgid "Significant improvements in the standard library:"
msgstr "標準函式庫中的顯著改進"
#: ../../whatsnew/3.12.rst:113
msgid "The :class:`pathlib.Path` class now supports subclassing"
msgstr ":class:`pathlib.Path` 類別現在支援子類別化"
#: ../../whatsnew/3.12.rst:114
msgid "The :mod:`os` module received several improvements for Windows support"
msgstr ""
#: ../../whatsnew/3.12.rst:115
msgid ""
"A :ref:`command-line interface <sqlite3-cli>` has been added to "
"the :mod:`sqlite3` module"
msgstr ""
"一個\\ :ref:`命令列介面 <sqlite3-cli>`\\ 已被加入 :mod:`sqlite3` 模組中"
#: ../../whatsnew/3.12.rst:117
msgid ""
":func:`isinstance` checks against :func:`runtime-checkable protocols "
"<typing.runtime_checkable>` enjoy a speed up of between two and 20 times"
msgstr ""
#: ../../whatsnew/3.12.rst:119
msgid ""
"The :mod:`asyncio` package has had a number of performance improvements, "
"with some benchmarks showing a 75% speed up."
msgstr ""
":mod:`asyncio` 套件進行了許多效能改進,一些基準測試顯示速度提高了 75%。"
#: ../../whatsnew/3.12.rst:121
msgid ""
"A :ref:`command-line interface <uuid-cli>` has been added to the :mod:`uuid` "
"module"
msgstr "一個\\ :ref:`命令列介面 <uuid-cli>`\\ 已被加入 :mod:`uuid` 模組中"
#: ../../whatsnew/3.12.rst:123
msgid ""
"Due to the changes in :ref:`PEP 701 <whatsnew312-pep701>`, producing tokens "
"via the :mod:`tokenize` module is up to 64% faster."
msgstr ""
#: ../../whatsnew/3.12.rst:126
msgid "Security improvements:"
msgstr "安全性改進:"
#: ../../whatsnew/3.12.rst:128
msgid ""
"Replace the builtin :mod:`hashlib` implementations of SHA1, SHA3, SHA2-384, "
"SHA2-512, and MD5 with formally verified code from the `HACL* <https://"
"github.com/hacl-star/hacl-star/>`__ project. These builtin implementations "
"remain as fallbacks that are only used when OpenSSL does not provide them."
msgstr ""
#: ../../whatsnew/3.12.rst:134
msgid "C API improvements:"
msgstr "C API 改進:"
#: ../../whatsnew/3.12.rst:136
msgid ":ref:`PEP 697 <whatsnew312-pep697>`, unstable C API tier"
msgstr ":ref:`PEP 697 <whatsnew312-pep697>`,不穩定 C API 層"
#: ../../whatsnew/3.12.rst:137
msgid ":ref:`PEP 683 <whatsnew312-pep683>`, immortal objects"
msgstr ""
#: ../../whatsnew/3.12.rst:139
msgid "CPython implementation improvements:"
msgstr "CPython 實作改進:"
#: ../../whatsnew/3.12.rst:141
msgid ":ref:`PEP 709 <whatsnew312-pep709>`, comprehension inlining"
msgstr ""
#: ../../whatsnew/3.12.rst:142
msgid ":ref:`CPython support <perf_profiling>` for the Linux ``perf`` profiler"
msgstr ""
#: ../../whatsnew/3.12.rst:143
msgid "Implement stack overflow protection on supported platforms"
msgstr ""
#: ../../whatsnew/3.12.rst:145
msgid "New typing features:"
msgstr "新增型別特性:"
#: ../../whatsnew/3.12.rst:147
msgid ""
":ref:`PEP 692 <whatsnew312-pep692>`, using :class:`~typing.TypedDict` to "
"annotate :term:`**kwargs <argument>`"
msgstr ""
":ref:`PEP 692 <whatsnew312-pep692>`、使用 :class:`~typing.TypedDict` 來標"
"註 :term:`**kwargs <argument>`"
#: ../../whatsnew/3.12.rst:149
msgid ":ref:`PEP 698 <whatsnew312-pep698>`, :func:`typing.override` decorator"
msgstr ":ref:`PEP 698 <whatsnew312-pep698>`、:func:`typing.override` 裝飾器"
#: ../../whatsnew/3.12.rst:151
msgid "Important deprecations, removals or restrictions:"
msgstr "重要的棄用、刪除或限制:"
#: ../../whatsnew/3.12.rst:153
msgid ""
":pep:`623`: Remove ``wstr`` from Unicode objects in Python's C API, reducing "
"the size of every :class:`str` object by at least 8 bytes."
msgstr ""
#: ../../whatsnew/3.12.rst:156
msgid ""
":pep:`632`: Remove the :mod:`!distutils` package. See :pep:`the migration "
"guide <0632#migration-advice>` for advice replacing the APIs it provided. "
"The third-party `Setuptools <https://setuptools.pypa.io/en/latest/deprecated/"
"distutils-legacy.html>`__ package continues to provide :mod:`!distutils`, if "
"you still require it in Python 3.12 and beyond."
msgstr ""
#: ../../whatsnew/3.12.rst:163
msgid ""
":gh:`95299`: Do not pre-install ``setuptools`` in virtual environments "
"created with :mod:`venv`. This means that ``distutils``, ``setuptools``, "
"``pkg_resources``, and ``easy_install`` will no longer available by default; "
"to access these run ``pip install setuptools`` in the :ref:`activated <venv-"
"explanation>` virtual environment."
msgstr ""
#: ../../whatsnew/3.12.rst:170
msgid ""
"The :mod:`!asynchat`, :mod:`!asyncore`, and :mod:`!imp` modules have been "
"removed, along with several :class:`unittest.TestCase` `method aliases "
"<unittest-TestCase-removed-aliases_>`_."
msgstr ""
":mod:`!asynchat`、:mod:`!asyncore` 和 :mod:`!imp` 模組以及幾"
"個 :class:`unittest.TestCase` 的\\ `方法別名 <unittest-TestCase-removed-"
"aliases_>`_\\ 已被刪除。"
#: ../../whatsnew/3.12.rst:176 ../../whatsnew/3.12.rst:1832
msgid "New Features"
msgstr "新增功能"
#: ../../whatsnew/3.12.rst:181
msgid "PEP 695: Type Parameter Syntax"
msgstr "PEP 695:型別參數語法"
#: ../../whatsnew/3.12.rst:183
msgid ""
"Generic classes and functions under :pep:`484` were declared using a verbose "
"syntax that left the scope of type parameters unclear and required explicit "
"declarations of variance."
msgstr ""
#: ../../whatsnew/3.12.rst:187
msgid ""
":pep:`695` introduces a new, more compact and explicit way to "
"create :ref:`generic classes <generic-classes>` and :ref:`functions <generic-"
"functions>`::"
msgstr ""
#: ../../whatsnew/3.12.rst:190
msgid ""
"def max[T](args: Iterable[T]) -> T:\n"
" ...\n"
"\n"
"class list[T]:\n"
" def __getitem__(self, index: int, /) -> T:\n"
" ...\n"
"\n"
" def append(self, element: T) -> None:\n"
" ..."
msgstr ""
"def max[T](args: Iterable[T]) -> T:\n"
" ...\n"
"\n"
"class list[T]:\n"
" def __getitem__(self, index: int, /) -> T:\n"
" ...\n"
"\n"
" def append(self, element: T) -> None:\n"
" ..."
#: ../../whatsnew/3.12.rst:200
msgid ""
"In addition, the PEP introduces a new way to declare :ref:`type aliases "
"<type-aliases>` using the :keyword:`type` statement, which creates an "
"instance of :class:`~typing.TypeAliasType`::"
msgstr ""
#: ../../whatsnew/3.12.rst:204
msgid "type Point = tuple[float, float]"
msgstr "type Point = tuple[float, float]"
#: ../../whatsnew/3.12.rst:206
msgid "Type aliases can also be :ref:`generic <generic-type-aliases>`::"
msgstr "型別別名也可以是\\ :ref:`泛型 <generic-type-aliases>`: ::"
#: ../../whatsnew/3.12.rst:208
msgid "type Point[T] = tuple[T, T]"
msgstr "type Point[T] = tuple[T, T]"
#: ../../whatsnew/3.12.rst:210
msgid ""
"The new syntax allows declaring :class:`~typing.TypeVarTuple` "
"and :class:`~typing.ParamSpec` parameters, as well "
"as :class:`~typing.TypeVar` parameters with bounds or constraints::"
msgstr ""
#: ../../whatsnew/3.12.rst:214
msgid ""
"type IntFunc[**P] = Callable[P, int] # ParamSpec\n"
"type LabeledTuple[*Ts] = tuple[str, *Ts] # TypeVarTuple\n"
"type HashableSequence[T: Hashable] = Sequence[T] # TypeVar with bound\n"
"type IntOrStrSequence[T: (int, str)] = Sequence[T] # TypeVar with "
"constraints"
msgstr ""
#: ../../whatsnew/3.12.rst:219
msgid ""
"The value of type aliases and the bound and constraints of type variables "
"created through this syntax are evaluated only on demand (see :ref:`lazy "
"evaluation <lazy-evaluation>`). This means type aliases are able to refer to "
"other types defined later in the file."
msgstr ""
#: ../../whatsnew/3.12.rst:224
msgid ""
"Type parameters declared through a type parameter list are visible within "
"the scope of the declaration and any nested scopes, but not in the outer "
"scope. For example, they can be used in the type annotations for the methods "
"of a generic class or in the class body. However, they cannot be used in the "
"module scope after the class is defined. See :ref:`type-params` for a "
"detailed description of the runtime semantics of type parameters."
msgstr ""
#: ../../whatsnew/3.12.rst:231
msgid ""
"In order to support these scoping semantics, a new kind of scope is "
"introduced, the :ref:`annotation scope <annotation-scopes>`. Annotation "
"scopes behave for the most part like function scopes, but interact "
"differently with enclosing class scopes. In Python 3.13, :term:`annotations "
"<annotation>` will also be evaluated in annotation scopes."
msgstr ""
#: ../../whatsnew/3.12.rst:237
msgid "See :pep:`695` for more details."
msgstr "詳情請見 :pep:`695`。"
#: ../../whatsnew/3.12.rst:239
msgid ""
"(PEP written by Eric Traut. Implementation by Jelle Zijlstra, Eric Traut, "
"and others in :gh:`103764`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:245
msgid "PEP 701: Syntactic formalization of f-strings"
msgstr ""
#: ../../whatsnew/3.12.rst:247
msgid ""
":pep:`701` lifts some restrictions on the usage of :term:`f-strings <f-"
"string>`. Expression components inside f-strings can now be any valid Python "
"expression, including strings reusing the same quote as the containing f-"
"string, multi-line expressions, comments, backslashes, and unicode escape "
"sequences. Let's cover these in detail:"
msgstr ""
#: ../../whatsnew/3.12.rst:253
msgid ""
"Quote reuse: in Python 3.11, reusing the same quotes as the enclosing f-"
"string raises a :exc:`SyntaxError`, forcing the user to either use other "
"available quotes (like using double quotes or triple quotes if the f-string "
"uses single quotes). In Python 3.12, you can now do things like this:"
msgstr ""
#: ../../whatsnew/3.12.rst:262
msgid ""
"Note that before this change there was no explicit limit in how f-strings "
"can be nested, but the fact that string quotes cannot be reused inside the "
"expression component of f-strings made it impossible to nest f-strings "
"arbitrarily. In fact, this is the most nested f-string that could be written:"
msgstr ""
#: ../../whatsnew/3.12.rst:270
msgid ""
"As now f-strings can contain any valid Python expression inside expression "
"components, it is now possible to nest f-strings arbitrarily:"
msgstr ""
#: ../../whatsnew/3.12.rst:276
msgid ""
"Multi-line expressions and comments: In Python 3.11, f-string expressions "
"must be defined in a single line, even if the expression within the f-string "
"could normally span multiple lines (like literal lists being defined over "
"multiple lines), making them harder to read. In Python 3.12 you can now "
"define f-strings spanning multiple lines, and add inline comments:"
msgstr ""
#: ../../whatsnew/3.12.rst:290
msgid ""
"Backslashes and unicode characters: before Python 3.12 f-string expressions "
"couldn't contain any ``\\`` character. This also affected "
"unicode :ref:`escape sequences <escape-sequences>` (such as ``\\N{snowman}"
"``) as these contain the ``\\N`` part that previously could not be part of "
"expression components of f-strings. Now, you can define expressions like "
"this:"
msgstr ""
#: ../../whatsnew/3.12.rst:303
msgid "See :pep:`701` for more details."
msgstr "詳情請見 :pep:`701`。"
#: ../../whatsnew/3.12.rst:305
msgid ""
"As a positive side-effect of how this feature has been implemented (by "
"parsing f-strings with :pep:`the PEG parser <617>`), now error messages for "
"f-strings are more precise and include the exact location of the error. For "
"example, in Python 3.11, the following f-string raises a :exc:`SyntaxError`:"
msgstr ""
#: ../../whatsnew/3.12.rst:310
msgid ""
">>> my_string = f\"{x z y}\" + f\"{1 + 1}\"\n"
" File \"<stdin>\", line 1\n"
" (x z y)\n"
" ^^^\n"
"SyntaxError: f-string: invalid syntax. Perhaps you forgot a comma?"
msgstr ""
">>> my_string = f\"{x z y}\" + f\"{1 + 1}\"\n"
" File \"<stdin>\", line 1\n"
" (x z y)\n"
" ^^^\n"
"SyntaxError: f-string: invalid syntax. Perhaps you forgot a comma?"
#: ../../whatsnew/3.12.rst:318
msgid ""
"but the error message doesn't include the exact location of the error within "
"the line and also has the expression artificially surrounded by parentheses. "
"In Python 3.12, as f-strings are parsed with the PEG parser, error messages "
"can be more precise and show the entire line:"
msgstr ""
#: ../../whatsnew/3.12.rst:322
msgid ""
">>> my_string = f\"{x z y}\" + f\"{1 + 1}\"\n"
" File \"<stdin>\", line 1\n"
" my_string = f\"{x z y}\" + f\"{1 + 1}\"\n"
" ^^^\n"
"SyntaxError: invalid syntax. Perhaps you forgot a comma?"
msgstr ""
">>> my_string = f\"{x z y}\" + f\"{1 + 1}\"\n"
" File \"<stdin>\", line 1\n"
" my_string = f\"{x z y}\" + f\"{1 + 1}\"\n"
" ^^^\n"
"SyntaxError: invalid syntax. Perhaps you forgot a comma?"
#: ../../whatsnew/3.12.rst:330
msgid ""
"(Contributed by Pablo Galindo, Batuhan Taskaya, Lysandros Nikolaou, Cristián "
"Maureira-Fredes and Marta Gómez in :gh:`102856`. PEP written by Pablo "
"Galindo, Batuhan Taskaya, Lysandros Nikolaou and Marta Gómez)."
msgstr ""
#: ../../whatsnew/3.12.rst:337
msgid "PEP 684: A Per-Interpreter GIL"
msgstr ""
#: ../../whatsnew/3.12.rst:339
msgid ""
":pep:`684` introduces a per-interpreter :term:`GIL <global interpreter "
"lock>`, so that sub-interpreters may now be created with a unique GIL per "
"interpreter. This allows Python programs to take full advantage of multiple "
"CPU cores. This is currently only available through the C-API, though a "
"Python API is :pep:`anticipated for 3.13 <554>`."
msgstr ""
#: ../../whatsnew/3.12.rst:345
msgid ""
"Use the new :c:func:`Py_NewInterpreterFromConfig` function to create an "
"interpreter with its own GIL:"
msgstr ""
#: ../../whatsnew/3.12.rst:348
msgid ""
"PyInterpreterConfig config = {\n"
" .check_multi_interp_extensions = 1,\n"
" .gil = PyInterpreterConfig_OWN_GIL,\n"
"};\n"
"PyThreadState *tstate = NULL;\n"
"PyStatus status = Py_NewInterpreterFromConfig(&tstate, &config);\n"
"if (PyStatus_Exception(status)) {\n"
" return -1;\n"
"}\n"
"/* The new interpreter is now active in the current thread. */"
msgstr ""
"PyInterpreterConfig config = {\n"
" .check_multi_interp_extensions = 1,\n"
" .gil = PyInterpreterConfig_OWN_GIL,\n"
"};\n"
"PyThreadState *tstate = NULL;\n"
"PyStatus status = Py_NewInterpreterFromConfig(&tstate, &config);\n"
"if (PyStatus_Exception(status)) {\n"
" return -1;\n"
"}\n"
"/* 新的直譯器現在會在當前執行緒中啟用。 */"
#: ../../whatsnew/3.12.rst:361
msgid ""
"For further examples how to use the C-API for sub-interpreters with a per-"
"interpreter GIL, see ``Modules/_xxsubinterpretersmodule.c``."
msgstr ""
#: ../../whatsnew/3.12.rst:364
msgid "(Contributed by Eric Snow in :gh:`104210`, etc.)"
msgstr "(由 Eric Snow 於 :gh:`104210` 等貢獻。)"
#: ../../whatsnew/3.12.rst:369
msgid "PEP 669: Low impact monitoring for CPython"
msgstr ""
#: ../../whatsnew/3.12.rst:371
msgid ""
":pep:`669` defines a new :mod:`API <sys.monitoring>` for profilers, "
"debuggers, and other tools to monitor events in CPython. It covers a wide "
"range of events, including calls, returns, lines, exceptions, jumps, and "
"more. This means that you only pay for what you use, providing support for "
"near-zero overhead debuggers and coverage tools. See :mod:`sys.monitoring` "
"for details."
msgstr ""
#: ../../whatsnew/3.12.rst:379
msgid "(Contributed by Mark Shannon in :gh:`103082`.)"
msgstr "(由 Mark Shannon 於 :gh:`103082` 中貢獻。)"
#: ../../whatsnew/3.12.rst:384
msgid "PEP 688: Making the buffer protocol accessible in Python"
msgstr ""
#: ../../whatsnew/3.12.rst:386
msgid ""
":pep:`688` introduces a way to use the :ref:`buffer protocol "
"<bufferobjects>` from Python code. Classes that implement "
"the :meth:`~object.__buffer__` method are now usable as buffer types."
msgstr ""
#: ../../whatsnew/3.12.rst:390
msgid ""
"The new :class:`collections.abc.Buffer` ABC provides a standard way to "
"represent buffer objects, for example in type annotations. The "
"new :class:`inspect.BufferFlags` enum represents the flags that can be used "
"to customize buffer creation. (Contributed by Jelle Zijlstra "
"in :gh:`102500`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:399
msgid "PEP 709: Comprehension inlining"
msgstr ""
#: ../../whatsnew/3.12.rst:401
msgid ""
"Dictionary, list, and set comprehensions are now inlined, rather than "
"creating a new single-use function object for each execution of the "
"comprehension. This speeds up execution of a comprehension by up to two "
"times. See :pep:`709` for further details."
msgstr ""
#: ../../whatsnew/3.12.rst:406
msgid ""
"Comprehension iteration variables remain isolated and don't overwrite a "
"variable of the same name in the outer scope, nor are they visible after the "
"comprehension. Inlining does result in a few visible behavior changes:"
msgstr ""
#: ../../whatsnew/3.12.rst:410
msgid ""
"There is no longer a separate frame for the comprehension in tracebacks, and "
"tracing/profiling no longer shows the comprehension as a function call."
msgstr ""
#: ../../whatsnew/3.12.rst:412
msgid ""
"The :mod:`symtable` module will no longer produce child symbol tables for "
"each comprehension; instead, the comprehension's locals will be included in "
"the parent function's symbol table."
msgstr ""
#: ../../whatsnew/3.12.rst:415
msgid ""
"Calling :func:`locals` inside a comprehension now includes variables from "
"outside the comprehension, and no longer includes the synthetic ``.0`` "
"variable for the comprehension \"argument\"."
msgstr ""
#: ../../whatsnew/3.12.rst:418
msgid ""
"A comprehension iterating directly over ``locals()`` (e.g. ``[k for k in "
"locals()]``) may see \"RuntimeError: dictionary changed size during "
"iteration\" when run under tracing (e.g. code coverage measurement). This is "
"the same behavior already seen in e.g. ``for k in locals():``. To avoid the "
"error, first create a list of keys to iterate over: ``keys = list(locals()); "
"[k for k in keys]``."
msgstr ""
#: ../../whatsnew/3.12.rst:425
msgid "(Contributed by Carl Meyer and Vladimir Matveev in :pep:`709`.)"
msgstr "(由 Carl Meyer 和 Vladimir Matveev 於 :pep:`709` 中貢獻。)"
#: ../../whatsnew/3.12.rst:428
msgid "Improved Error Messages"
msgstr ""
#: ../../whatsnew/3.12.rst:430
msgid ""
"Modules from the standard library are now potentially suggested as part of "
"the error messages displayed by the interpreter when a :exc:`NameError` is "
"raised to the top level. (Contributed by Pablo Galindo in :gh:`98254`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:439
msgid ""
"Improve the error suggestion for :exc:`NameError` exceptions for instances. "
"Now if a :exc:`NameError` is raised in a method and the instance has an "
"attribute that's exactly equal to the name in the exception, the suggestion "
"will include ``self.<NAME>`` instead of the closest match in the method "
"scope. (Contributed by Pablo Galindo in :gh:`99139`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:459
msgid ""
"Improve the :exc:`SyntaxError` error message when the user types ``import x "
"from y`` instead of ``from y import x``. (Contributed by Pablo Galindo "
"in :gh:`98931`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:469
msgid ""
":exc:`ImportError` exceptions raised from failed ``from <module> import "
"<name>`` statements now include suggestions for the value of ``<name>`` "
"based on the available names in ``<module>``. (Contributed by Pablo Galindo "
"in :gh:`91058`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:480
msgid "New Features Related to Type Hints"
msgstr ""
#: ../../whatsnew/3.12.rst:482
msgid ""
"This section covers major changes affecting :pep:`type hints <484>` and "
"the :mod:`typing` module."
msgstr ""
#: ../../whatsnew/3.12.rst:488
msgid "PEP 692: Using ``TypedDict`` for more precise ``**kwargs`` typing"
msgstr ""
#: ../../whatsnew/3.12.rst:490
msgid ""
"Typing ``**kwargs`` in a function signature as introduced by :pep:`484` "
"allowed for valid annotations only in cases where all of the ``**kwargs`` "
"were of the same type."
msgstr ""
#: ../../whatsnew/3.12.rst:494
msgid ""
":pep:`692` specifies a more precise way of typing ``**kwargs`` by relying on "
"typed dictionaries::"
msgstr ""
#: ../../whatsnew/3.12.rst:497
msgid ""
"from typing import TypedDict, Unpack\n"
"\n"
"class Movie(TypedDict):\n"
" name: str\n"
" year: int\n"
"\n"
"def foo(**kwargs: Unpack[Movie]): ..."
msgstr ""
"from typing import TypedDict, Unpack\n"
"\n"
"class Movie(TypedDict):\n"
" name: str\n"
" year: int\n"
"\n"
"def foo(**kwargs: Unpack[Movie]): ..."
#: ../../whatsnew/3.12.rst:505
msgid "See :pep:`692` for more details."
msgstr "詳情請見 :pep:`692`。"
#: ../../whatsnew/3.12.rst:507
msgid "(Contributed by Franek Magiera in :gh:`103629`.)"
msgstr "(由 Franek Magiera 於 :gh:`103629` 中貢獻。)"
#: ../../whatsnew/3.12.rst:512
msgid "PEP 698: Override Decorator for Static Typing"
msgstr ""
#: ../../whatsnew/3.12.rst:514
msgid ""
"A new decorator :func:`typing.override` has been added to the :mod:`typing` "
"module. It indicates to type checkers that the method is intended to "
"override a method in a superclass. This allows type checkers to catch "
"mistakes where a method that is intended to override something in a base "
"class does not in fact do so."
msgstr ""
#: ../../whatsnew/3.12.rst:520
msgid "Example::"
msgstr "範例: ::"
#: ../../whatsnew/3.12.rst:522
msgid ""
"from typing import override\n"
"\n"
"class Base:\n"
" def get_color(self) -> str:\n"
" return \"blue\"\n"
"\n"
"class GoodChild(Base):\n"
" @override # ok: overrides Base.get_color\n"
" def get_color(self) -> str:\n"
" return \"yellow\"\n"
"\n"
"class BadChild(Base):\n"
" @override # type checker error: does not override Base.get_color\n"
" def get_colour(self) -> str:\n"
" return \"red\""
msgstr ""
#: ../../whatsnew/3.12.rst:538
msgid "See :pep:`698` for more details."
msgstr "詳情請見 :pep:`698`。"
#: ../../whatsnew/3.12.rst:540
msgid "(Contributed by Steven Troxler in :gh:`101561`.)"
msgstr "(由 Steven Troxler 於 :gh:`101561` 中貢獻。)"
#: ../../whatsnew/3.12.rst:543
msgid "Other Language Changes"
msgstr "其他語言更動"
#: ../../whatsnew/3.12.rst:545
msgid ""
"The parser now raises :exc:`SyntaxError` when parsing source code containing "
"null bytes. (Contributed by Pablo Galindo in :gh:`96670`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:548
msgid ""
"A backslash-character pair that is not a valid escape sequence now generates "
"a :exc:`SyntaxWarning`, instead of :exc:`DeprecationWarning`. For example, "
"``re.compile(\"\\d+\\.\\d+\")`` now emits a :exc:`SyntaxWarning` "
"(``\"\\d\"`` is an invalid escape sequence, use raw strings for regular "
"expression: ``re.compile(r\"\\d+\\.\\d+\")``). In a future Python "
"version, :exc:`SyntaxError` will eventually be raised, instead "
"of :exc:`SyntaxWarning`. (Contributed by Victor Stinner in :gh:`98401`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:557
msgid ""
"Octal escapes with value larger than ``0o377`` (ex: ``\"\\477\"``), "
"deprecated in Python 3.11, now produce a :exc:`SyntaxWarning`, instead "
"of :exc:`DeprecationWarning`. In a future Python version they will be "
"eventually a :exc:`SyntaxError`. (Contributed by Victor Stinner "
"in :gh:`98401`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:563
msgid ""
"Variables used in the target part of comprehensions that are not stored to "
"can now be used in assignment expressions (``:=``). For example, in ``[(b := "
"1) for a, b.prop in some_iter]``, the assignment to ``b`` is now allowed. "
"Note that assigning to variables stored to in the target part of "
"comprehensions (like ``a``) is still disallowed, as per :pep:`572`. "
"(Contributed by Nikita Sobolev in :gh:`100581`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:570
msgid ""
"Exceptions raised in a class or type's ``__set_name__`` method are no longer "
"wrapped by a :exc:`RuntimeError`. Context information is added to the "
"exception as a :pep:`678` note. (Contributed by Irit Katriel in :gh:`77757`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:574
msgid ""
"When a ``try-except*`` construct handles the entire :exc:`ExceptionGroup` "
"and raises one other exception, that exception is no longer wrapped in "
"an :exc:`ExceptionGroup`. Also changed in version 3.11.4. (Contributed by "
"Irit Katriel in :gh:`103590`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:579
msgid ""
"The Garbage Collector now runs only on the eval breaker mechanism of the "
"Python bytecode evaluation loop instead of object allocations. The GC can "
"also run when :c:func:`PyErr_CheckSignals` is called so C extensions that "
"need to run for a long time without executing any Python code also have a "
"chance to execute the GC periodically. (Contributed by Pablo Galindo "
"in :gh:`97922`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:586
msgid ""
"All builtin and extension callables expecting boolean parameters now accept "
"arguments of any type instead of just :class:`bool` and :class:`int`. "
"(Contributed by Serhiy Storchaka in :gh:`60203`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:590
msgid ""
":class:`memoryview` now supports the half-float type (the \"e\" format "
"code). (Contributed by Donghee Na and Antoine Pitrou in :gh:`90751`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:593
msgid ""
":class:`slice` objects are now hashable, allowing them to be used as dict "
"keys and set items. (Contributed by Will Bradshaw, Furkan Onder, and Raymond "
"Hettinger in :gh:`101264`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:596
msgid ""
":func:`sum` now uses Neumaier summation to improve accuracy and "
"commutativity when summing floats or mixed ints and floats. (Contributed by "
"Raymond Hettinger in :gh:`100425`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:600
msgid ""
":func:`ast.parse` now raises :exc:`SyntaxError` instead of :exc:`ValueError` "
"when parsing source code containing null bytes. (Contributed by Pablo "
"Galindo in :gh:`96670`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:604
msgid ""
"The extraction methods in :mod:`tarfile`, and :func:`shutil.unpack_archive`, "
"have a new a *filter* argument that allows limiting tar features than may be "
"surprising or dangerous, such as creating files outside the destination "
"directory. See :ref:`tarfile extraction filters <tarfile-extraction-filter>` "
"for details. In Python 3.14, the default will switch to ``'data'``. "
"(Contributed by Petr Viktorin in :pep:`706`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:612
msgid ""
":class:`types.MappingProxyType` instances are now hashable if the underlying "
"mapping is hashable. (Contributed by Serhiy Storchaka in :gh:`87995`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:616
msgid ""
"Add :ref:`support for the perf profiler <perf_profiling>` through the new "
"environment variable :envvar:`PYTHONPERFSUPPORT` and command-line "
"option :option:`-X perf <-X>`, as well as the "
"new :func:`sys.activate_stack_trampoline`, :func:`sys.deactivate_stack_trampoline`, "
"and :func:`sys.is_stack_trampoline_active` functions. (Design by Pablo "
"Galindo. Contributed by Pablo Galindo and Christian Heimes with "
"contributions from Gregory P. Smith [Google] and Mark Shannon "
"in :gh:`96123`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:628
msgid "New Modules"
msgstr "新增模組"
#: ../../whatsnew/3.12.rst:630
msgid "None."
msgstr ""
#: ../../whatsnew/3.12.rst:634
msgid "Improved Modules"
msgstr "改進的模組"
#: ../../whatsnew/3.12.rst:637
msgid "array"
msgstr "array"
#: ../../whatsnew/3.12.rst:639
msgid ""
"The :class:`array.array` class now supports subscripting, making it "
"a :term:`generic type`. (Contributed by Jelle Zijlstra in :gh:`98658`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:643
msgid "asyncio"
msgstr "asyncio"
#: ../../whatsnew/3.12.rst:645
msgid ""
"The performance of writing to sockets in :mod:`asyncio` has been "
"significantly improved. ``asyncio`` now avoids unnecessary copying when "
"writing to sockets and uses :meth:`~socket.socket.sendmsg` if the platform "
"supports it. (Contributed by Kumar Aditya in :gh:`91166`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:650
msgid ""
"Add :func:`asyncio.eager_task_factory` "
"and :func:`asyncio.create_eager_task_factory` functions to allow opting an "
"event loop in to eager task execution, making some use-cases 2x to 5x "
"faster. (Contributed by Jacob Bower & Itamar Oren "
"in :gh:`102853`, :gh:`104140`, and :gh:`104138`)"
msgstr ""
#: ../../whatsnew/3.12.rst:655
msgid ""
"On Linux, :mod:`asyncio` uses :class:`asyncio.PidfdChildWatcher` by default "
"if :func:`os.pidfd_open` is available and functional instead "
"of :class:`asyncio.ThreadedChildWatcher`. (Contributed by Kumar Aditya "
"in :gh:`98024`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:660
msgid ""
"The event loop now uses the best available child watcher for each platform "
"(:class:`asyncio.PidfdChildWatcher` if supported "
"and :class:`asyncio.ThreadedChildWatcher` otherwise), so manually "
"configuring a child watcher is not recommended. (Contributed by Kumar Aditya "
"in :gh:`94597`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:666
msgid ""
"Add *loop_factory* parameter to :func:`asyncio.run` to allow specifying a "
"custom event loop factory. (Contributed by Kumar Aditya in :gh:`99388`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:670
msgid ""
"Add C implementation of :func:`asyncio.current_task` for 4x-6x speedup. "
"(Contributed by Itamar Oren and Pranav Thulasiram Bhat in :gh:`100344`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:673
msgid ""
":func:`asyncio.iscoroutine` now returns ``False`` for generators "
"as :mod:`asyncio` does not support legacy generator-based coroutines. "
"(Contributed by Kumar Aditya in :gh:`102748`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:677
msgid ""
":func:`asyncio.wait` and :func:`asyncio.as_completed` now accepts generators "
"yielding tasks. (Contributed by Kumar Aditya in :gh:`78530`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:682
msgid "calendar"
msgstr "calendar"
#: ../../whatsnew/3.12.rst:684
msgid ""
"Add enums :data:`calendar.Month` and :data:`calendar.Day` defining months of "
"the year and days of the week. (Contributed by Prince Roshan "
"in :gh:`103636`.)"
msgstr ""
#: ../../whatsnew/3.12.rst:689
msgid "csv"
msgstr "csv"
#: ../../whatsnew/3.12.rst:691
msgid ""
"Add :const:`csv.QUOTE_NOTNULL` and :const:`csv.QUOTE_STRINGS` flags to "
"provide finer grained control of ``None`` and empty strings "
"by :class:`~csv.reader` and :class:`~csv.writer` objects."