forked from python/python-docs-tr
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path3.4.html
More file actions
2583 lines (2533 loc) · 339 KB
/
3.4.html
File metadata and controls
2583 lines (2533 loc) · 339 KB
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
<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
<meta property="og:title" content="What’s New In Python 3.4" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://docs.python.org/3/whatsnew/3.4.html" />
<meta property="og:site_name" content="Python documentation" />
<meta property="og:description" content="Author, R. David Murray < rdmurray@bitdance.com> (Editor),. This article explains the new features in Python 3.4, compared to 3.3. Python 3.4 was released on March 16, 2014. For full details, see t..." />
<meta property="og:image" content="https://docs.python.org/3/_static/og-image.png" />
<meta property="og:image:alt" content="Python documentation" />
<meta name="description" content="Author, R. David Murray < rdmurray@bitdance.com> (Editor),. This article explains the new features in Python 3.4, compared to 3.3. Python 3.4 was released on March 16, 2014. For full details, see t..." />
<meta property="og:image:width" content="200" />
<meta property="og:image:height" content="200" />
<meta name="theme-color" content="#3776ab" />
<title>What’s New In Python 3.4 — Python 3.11.5 belgelendirmesi</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?digest=b37c26da2f7529d09fe70b41c4b2133fe4931a90" />
<link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css" />
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/sphinx_highlight.js"></script>
<script src="../_static/translations.js"></script>
<script src="../_static/sidebar.js"></script>
<link rel="search" type="application/opensearchdescription+xml"
title="Python 3.11.5 belgelendirmesi içinde ara"
href="../_static/opensearch.xml"/>
<link rel="author" title="Bu belgeler hakkında" href="../about.html" />
<link rel="index" title="Dizin" href="../genindex.html" />
<link rel="search" title="Ara" href="../search.html" />
<link rel="copyright" title="Telif Hakkı" href="../copyright.html" />
<link rel="next" title="What’s New In Python 3.3" href="3.3.html" />
<link rel="prev" title="What’s New In Python 3.5" href="3.5.html" />
<link rel="canonical" href="https://docs.python.org/3/whatsnew/3.4.html" />
<style>
@media only screen {
table.full-width-table {
width: 100%;
}
}
</style>
<link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
<link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
<script type="text/javascript" src="../_static/copybutton.js"></script>
<script type="text/javascript" src="../_static/menu.js"></script>
<script type="text/javascript" src="../_static/search-focus.js"></script>
<script type="text/javascript" src="../_static/themetoggle.js"></script>
</head>
<body>
<div class="mobile-nav">
<input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
<nav class="nav-content" role="navigation">
<label for="menuToggler" class="toggler__label">
<span></span>
</label>
<span class="nav-items-wrapper">
<a href="https://www.python.org/" class="nav-logo">
<img src="../_static/py.svg" alt="Logo"/>
</a>
<span class="version_switcher_placeholder"></span>
<form role="search" class="search" action="../search.html" method="get">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
<path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>
</svg>
<input placeholder="Hızlı Arama" aria-label="Hızlı Arama" type="search" name="q" />
<input type="submit" value="Git"/>
</form>
</span>
</nav>
<div class="menu-wrapper">
<nav class="menu" role="navigation" aria-label="main navigation">
<div class="language_switcher_placeholder"></div>
<label class="theme-selector-label">
Theme
<select class="theme-selector" oninput="activateTheme(this.value)">
<option value="auto" selected>Auto</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</label>
<div>
<h3><a href="../contents.html">İçindekiler</a></h3>
<ul>
<li><a class="reference internal" href="#">What’s New In Python 3.4</a><ul>
<li><a class="reference internal" href="#summary-release-highlights">Summary – Release Highlights</a></li>
<li><a class="reference internal" href="#new-features">New Features</a><ul>
<li><a class="reference internal" href="#pep-453-explicit-bootstrapping-of-pip-in-python-installations">PEP 453: Explicit Bootstrapping of PIP in Python Installations</a><ul>
<li><a class="reference internal" href="#bootstrapping-pip-by-default">Bootstrapping pip By Default</a></li>
<li><a class="reference internal" href="#documentation-changes">Documentation Changes</a></li>
</ul>
</li>
<li><a class="reference internal" href="#pep-446-newly-created-file-descriptors-are-non-inheritable">PEP 446: Newly Created File Descriptors Are Non-Inheritable</a></li>
<li><a class="reference internal" href="#improvements-to-codec-handling">Improvements to Codec Handling</a></li>
<li><a class="reference internal" href="#pep-451-a-modulespec-type-for-the-import-system">PEP 451: A ModuleSpec Type for the Import System</a></li>
<li><a class="reference internal" href="#other-language-changes">Other Language Changes</a></li>
</ul>
</li>
<li><a class="reference internal" href="#new-modules">New Modules</a><ul>
<li><a class="reference internal" href="#asyncio">asyncio</a></li>
<li><a class="reference internal" href="#ensurepip">ensurepip</a></li>
<li><a class="reference internal" href="#enum">enum</a></li>
<li><a class="reference internal" href="#pathlib">pathlib</a></li>
<li><a class="reference internal" href="#selectors">selectors</a></li>
<li><a class="reference internal" href="#statistics">statistics</a></li>
<li><a class="reference internal" href="#tracemalloc">tracemalloc</a></li>
</ul>
</li>
<li><a class="reference internal" href="#improved-modules">Improved Modules</a><ul>
<li><a class="reference internal" href="#abc">abc</a></li>
<li><a class="reference internal" href="#aifc">aifc</a></li>
<li><a class="reference internal" href="#argparse">argparse</a></li>
<li><a class="reference internal" href="#audioop">audioop</a></li>
<li><a class="reference internal" href="#base64">base64</a></li>
<li><a class="reference internal" href="#collections">collections</a></li>
<li><a class="reference internal" href="#colorsys">colorsys</a></li>
<li><a class="reference internal" href="#contextlib">contextlib</a></li>
<li><a class="reference internal" href="#dbm">dbm</a></li>
<li><a class="reference internal" href="#dis">dis</a></li>
<li><a class="reference internal" href="#doctest">doctest</a></li>
<li><a class="reference internal" href="#email">email</a></li>
<li><a class="reference internal" href="#filecmp">filecmp</a></li>
<li><a class="reference internal" href="#functools">functools</a></li>
<li><a class="reference internal" href="#gc">gc</a></li>
<li><a class="reference internal" href="#glob">glob</a></li>
<li><a class="reference internal" href="#hashlib">hashlib</a></li>
<li><a class="reference internal" href="#hmac">hmac</a></li>
<li><a class="reference internal" href="#html">html</a></li>
<li><a class="reference internal" href="#http">http</a></li>
<li><a class="reference internal" href="#idlelib-and-idle">idlelib and IDLE</a></li>
<li><a class="reference internal" href="#importlib">importlib</a></li>
<li><a class="reference internal" href="#inspect">inspect</a></li>
<li><a class="reference internal" href="#ipaddress">ipaddress</a></li>
<li><a class="reference internal" href="#logging">logging</a></li>
<li><a class="reference internal" href="#marshal">marshal</a></li>
<li><a class="reference internal" href="#mmap">mmap</a></li>
<li><a class="reference internal" href="#multiprocessing">multiprocessing</a></li>
<li><a class="reference internal" href="#operator">operator</a></li>
<li><a class="reference internal" href="#os">os</a></li>
<li><a class="reference internal" href="#pdb">pdb</a></li>
<li><a class="reference internal" href="#pickle">pickle</a></li>
<li><a class="reference internal" href="#plistlib">plistlib</a></li>
<li><a class="reference internal" href="#poplib">poplib</a></li>
<li><a class="reference internal" href="#pprint">pprint</a></li>
<li><a class="reference internal" href="#pty">pty</a></li>
<li><a class="reference internal" href="#pydoc">pydoc</a></li>
<li><a class="reference internal" href="#re">re</a></li>
<li><a class="reference internal" href="#resource">resource</a></li>
<li><a class="reference internal" href="#select">select</a></li>
<li><a class="reference internal" href="#shelve">shelve</a></li>
<li><a class="reference internal" href="#shutil">shutil</a></li>
<li><a class="reference internal" href="#smtpd">smtpd</a></li>
<li><a class="reference internal" href="#smtplib">smtplib</a></li>
<li><a class="reference internal" href="#socket">socket</a></li>
<li><a class="reference internal" href="#sqlite3">sqlite3</a></li>
<li><a class="reference internal" href="#ssl">ssl</a></li>
<li><a class="reference internal" href="#stat">stat</a></li>
<li><a class="reference internal" href="#struct">struct</a></li>
<li><a class="reference internal" href="#subprocess">subprocess</a></li>
<li><a class="reference internal" href="#sunau">sunau</a></li>
<li><a class="reference internal" href="#sys">sys</a></li>
<li><a class="reference internal" href="#tarfile">tarfile</a></li>
<li><a class="reference internal" href="#textwrap">textwrap</a></li>
<li><a class="reference internal" href="#threading">threading</a></li>
<li><a class="reference internal" href="#traceback">traceback</a></li>
<li><a class="reference internal" href="#types">types</a></li>
<li><a class="reference internal" href="#urllib">urllib</a></li>
<li><a class="reference internal" href="#unittest">unittest</a></li>
<li><a class="reference internal" href="#venv">venv</a></li>
<li><a class="reference internal" href="#wave">wave</a></li>
<li><a class="reference internal" href="#weakref">weakref</a></li>
<li><a class="reference internal" href="#xml-etree">xml.etree</a></li>
<li><a class="reference internal" href="#zipfile">zipfile</a></li>
</ul>
</li>
<li><a class="reference internal" href="#cpython-implementation-changes">CPython Implementation Changes</a><ul>
<li><a class="reference internal" href="#pep-445-customization-of-cpython-memory-allocators">PEP 445: Customization of CPython Memory Allocators</a></li>
<li><a class="reference internal" href="#pep-442-safe-object-finalization">PEP 442: Safe Object Finalization</a></li>
<li><a class="reference internal" href="#pep-456-secure-and-interchangeable-hash-algorithm">PEP 456: Secure and Interchangeable Hash Algorithm</a></li>
<li><a class="reference internal" href="#pep-436-argument-clinic">PEP 436: Argument Clinic</a></li>
<li><a class="reference internal" href="#other-build-and-c-api-changes">Other Build and C API Changes</a></li>
<li><a class="reference internal" href="#other-improvements">Other Improvements</a></li>
<li><a class="reference internal" href="#significant-optimizations">Significant Optimizations</a></li>
</ul>
</li>
<li><a class="reference internal" href="#deprecated">Deprecated</a><ul>
<li><a class="reference internal" href="#deprecations-in-the-python-api">Deprecations in the Python API</a></li>
<li><a class="reference internal" href="#deprecated-features">Deprecated Features</a></li>
</ul>
</li>
<li><a class="reference internal" href="#removed">Removed</a><ul>
<li><a class="reference internal" href="#operating-systems-no-longer-supported">Operating Systems No Longer Supported</a></li>
<li><a class="reference internal" href="#api-and-feature-removals">API and Feature Removals</a></li>
<li><a class="reference internal" href="#code-cleanups">Code Cleanups</a></li>
</ul>
</li>
<li><a class="reference internal" href="#porting-to-python-3-4">Porting to Python 3.4</a><ul>
<li><a class="reference internal" href="#changes-in-python-command-behavior">Changes in ‘python’ Command Behavior</a></li>
<li><a class="reference internal" href="#changes-in-the-python-api">Changes in the Python API</a></li>
<li><a class="reference internal" href="#changes-in-the-c-api">Changes in the C API</a></li>
</ul>
</li>
<li><a class="reference internal" href="#changed-in-3-4-3">Changed in 3.4.3</a><ul>
<li><a class="reference internal" href="#pep-476-enabling-certificate-verification-by-default-for-stdlib-http-clients">PEP 476: Enabling certificate verification by default for stdlib http clients</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div>
<h4>Önceki konu</h4>
<p class="topless"><a href="3.5.html"
title="önceki bölüm">What’s New In Python 3.5</a></p>
</div>
<div>
<h4>Sonraki konu</h4>
<p class="topless"><a href="3.3.html"
title="sonraki bölüm">What’s New In Python 3.3</a></p>
</div>
<div role="note" aria-label="source link">
<h3>Bu Sayfa</h3>
<ul class="this-page-menu">
<li><a href="../bugs.html">Hata Bildir</a></li>
<li>
<a href="https://github.com/python/cpython/blob/3.11/Doc/whatsnew/3.4.rst"
rel="nofollow">Kaynağı Göster
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Gezinti</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="Genel Endeks"
accesskey="I">dizin</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Modül Dizini"
>modülleri</a> |</li>
<li class="right" >
<a href="3.3.html" title="What’s New In Python 3.3"
accesskey="N">sonraki</a> |</li>
<li class="right" >
<a href="3.5.html" title="What’s New In Python 3.5"
accesskey="P">önceki</a> |</li>
<li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="https://www.python.org/">Python</a> »</li>
<li class="switchers">
<div class="language_switcher_placeholder"></div>
<div class="version_switcher_placeholder"></div>
</li>
<li>
</li>
<li id="cpython-language-and-version">
<a href="../index.html">3.11.5 Documentation</a> »
</li>
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">What’s New in Python</a> »</li>
<li class="nav-item nav-item-this"><a href="">What’s New In Python 3.4</a></li>
<li class="right">
<div class="inline-search" role="search">
<form class="inline-search" action="../search.html" method="get">
<input placeholder="Hızlı Arama" aria-label="Hızlı Arama" type="search" name="q" id="search-box" />
<input type="submit" value="Git" />
</form>
</div>
|
</li>
<li class="right">
<label class="theme-selector-label">
Theme
<select class="theme-selector" oninput="activateTheme(this.value)">
<option value="auto" selected>Auto</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</label> |</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="what-s-new-in-python-3-4">
<h1>What’s New In Python 3.4<a class="headerlink" href="#what-s-new-in-python-3-4" title="Permalink to this heading">¶</a></h1>
<dl class="field-list simple">
<dt class="field-odd">Author<span class="colon">:</span></dt>
<dd class="field-odd"><p>R. David Murray <<a class="reference external" href="mailto:rdmurray%40bitdance.com">rdmurray<span>@</span>bitdance<span>.</span>com</a>> (Editor)</p>
</dd>
</dl>
<p>This article explains the new features in Python 3.4, compared to 3.3.
Python 3.4 was released on March 16, 2014. For full details, see the
<a class="reference external" href="https://docs.python.org/3.4/whatsnew/changelog.html">changelog</a>.</p>
<div class="admonition seealso">
<p class="admonition-title">Ayrıca bakınız</p>
<p><span class="target" id="index-0"></span><a class="pep reference external" href="https://peps.python.org/pep-0429/"><strong>PEP 429</strong></a> – Python 3.4 Release Schedule</p>
</div>
<section id="summary-release-highlights">
<h2>Summary – Release Highlights<a class="headerlink" href="#summary-release-highlights" title="Permalink to this heading">¶</a></h2>
<p>New syntax features:</p>
<ul class="simple">
<li><p>No new syntax features were added in Python 3.4.</p></li>
</ul>
<p>Other new features:</p>
<ul class="simple">
<li><p><a class="reference internal" href="#whatsnew-pep-453"><span class="std std-ref">pip should always be available</span></a> (<span class="target" id="index-1"></span><a class="pep reference external" href="https://peps.python.org/pep-0453/"><strong>PEP 453</strong></a>).</p></li>
<li><p><a class="reference internal" href="#whatsnew-pep-446"><span class="std std-ref">Newly created file descriptors are non-inheritable</span></a>
(<span class="target" id="index-2"></span><a class="pep reference external" href="https://peps.python.org/pep-0446/"><strong>PEP 446</strong></a>).</p></li>
<li><p>command line option for <a class="reference internal" href="#whatsnew-isolated-mode"><span class="std std-ref">isolated mode</span></a>
(<a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=16499">bpo-16499</a>).</p></li>
<li><p><a class="reference internal" href="#codec-handling-improvements"><span class="std std-ref">improvements in the handling of codecs</span></a>
that are not text encodings (multiple issues).</p></li>
<li><p><a class="reference internal" href="#whatsnew-pep-451"><span class="std std-ref">A ModuleSpec Type</span></a> for the Import System
(<span class="target" id="index-3"></span><a class="pep reference external" href="https://peps.python.org/pep-0451/"><strong>PEP 451</strong></a>). (Affects importer authors.)</p></li>
<li><p>The <a class="reference internal" href="../library/marshal.html#module-marshal" title="marshal: Convert Python objects to streams of bytes and back (with different constraints)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">marshal</span></code></a> format has been made <a class="reference internal" href="#whatsnew-marshal-3"><span class="std std-ref">more compact and efficient</span></a> (<a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=16475">bpo-16475</a>).</p></li>
</ul>
<p>New library modules:</p>
<ul class="simple">
<li><p><a class="reference internal" href="../library/asyncio.html#module-asyncio" title="asyncio: Asynchronous I/O."><code class="xref py py-mod docutils literal notranslate"><span class="pre">asyncio</span></code></a>: <a class="reference internal" href="#whatsnew-asyncio"><span class="std std-ref">New provisional API for asynchronous IO</span></a> (<span class="target" id="index-4"></span><a class="pep reference external" href="https://peps.python.org/pep-3156/"><strong>PEP 3156</strong></a>).</p></li>
<li><p><a class="reference internal" href="../library/ensurepip.html#module-ensurepip" title="ensurepip: Bootstrapping the "pip" installer into an existing Python installation or virtual environment."><code class="xref py py-mod docutils literal notranslate"><span class="pre">ensurepip</span></code></a>: <a class="reference internal" href="#whatsnew-ensurepip"><span class="std std-ref">Bootstrapping the pip installer</span></a>
(<span class="target" id="index-5"></span><a class="pep reference external" href="https://peps.python.org/pep-0453/"><strong>PEP 453</strong></a>).</p></li>
<li><p><a class="reference internal" href="../library/enum.html#module-enum" title="enum: Implementation of an enumeration class."><code class="xref py py-mod docutils literal notranslate"><span class="pre">enum</span></code></a>: <a class="reference internal" href="#whatsnew-enum"><span class="std std-ref">Support for enumeration types</span></a>
(<span class="target" id="index-6"></span><a class="pep reference external" href="https://peps.python.org/pep-0435/"><strong>PEP 435</strong></a>).</p></li>
<li><p><a class="reference internal" href="../library/pathlib.html#module-pathlib" title="pathlib: Object-oriented filesystem paths"><code class="xref py py-mod docutils literal notranslate"><span class="pre">pathlib</span></code></a>: <a class="reference internal" href="#whatsnew-pathlib"><span class="std std-ref">Object-oriented filesystem paths</span></a>
(<span class="target" id="index-7"></span><a class="pep reference external" href="https://peps.python.org/pep-0428/"><strong>PEP 428</strong></a>).</p></li>
<li><p><a class="reference internal" href="../library/selectors.html#module-selectors" title="selectors: High-level I/O multiplexing."><code class="xref py py-mod docutils literal notranslate"><span class="pre">selectors</span></code></a>: <a class="reference internal" href="#whatsnew-selectors"><span class="std std-ref">High-level and efficient I/O multiplexing</span></a>, built upon the <a class="reference internal" href="../library/select.html#module-select" title="select: Wait for I/O completion on multiple streams."><code class="xref py py-mod docutils literal notranslate"><span class="pre">select</span></code></a> module primitives (part
of <span class="target" id="index-8"></span><a class="pep reference external" href="https://peps.python.org/pep-3156/"><strong>PEP 3156</strong></a>).</p></li>
<li><p><a class="reference internal" href="../library/statistics.html#module-statistics" title="statistics: Mathematical statistics functions"><code class="xref py py-mod docutils literal notranslate"><span class="pre">statistics</span></code></a>: A basic <a class="reference internal" href="#whatsnew-statistics"><span class="std std-ref">numerically stable statistics library</span></a> (<span class="target" id="index-9"></span><a class="pep reference external" href="https://peps.python.org/pep-0450/"><strong>PEP 450</strong></a>).</p></li>
<li><p><a class="reference internal" href="../library/tracemalloc.html#module-tracemalloc" title="tracemalloc: Trace memory allocations."><code class="xref py py-mod docutils literal notranslate"><span class="pre">tracemalloc</span></code></a>: <a class="reference internal" href="#whatsnew-tracemalloc"><span class="std std-ref">Trace Python memory allocations</span></a> (<span class="target" id="index-10"></span><a class="pep reference external" href="https://peps.python.org/pep-0454/"><strong>PEP 454</strong></a>).</p></li>
</ul>
<p>Significantly improved library modules:</p>
<ul class="simple">
<li><p><a class="reference internal" href="#whatsnew-singledispatch"><span class="std std-ref">Single-dispatch generic functions</span></a> in
<a class="reference internal" href="../library/functools.html#module-functools" title="functools: Higher-order functions and operations on callable objects."><code class="xref py py-mod docutils literal notranslate"><span class="pre">functools</span></code></a> (<span class="target" id="index-11"></span><a class="pep reference external" href="https://peps.python.org/pep-0443/"><strong>PEP 443</strong></a>).</p></li>
<li><p>New <a class="reference internal" href="../library/pickle.html#module-pickle" title="pickle: Convert Python objects to streams of bytes and back."><code class="xref py py-mod docutils literal notranslate"><span class="pre">pickle</span></code></a> <a class="reference internal" href="#whatsnew-protocol-4"><span class="std std-ref">protocol 4</span></a> (<span class="target" id="index-12"></span><a class="pep reference external" href="https://peps.python.org/pep-3154/"><strong>PEP 3154</strong></a>).</p></li>
<li><p><a class="reference internal" href="../library/multiprocessing.html#module-multiprocessing" title="multiprocessing: Process-based parallelism."><code class="xref py py-mod docutils literal notranslate"><span class="pre">multiprocessing</span></code></a> now has <a class="reference internal" href="#whatsnew-multiprocessing-no-fork"><span class="std std-ref">an option to avoid using os.fork
on Unix</span></a> (<a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=8713">bpo-8713</a>).</p></li>
<li><p><a class="reference internal" href="../library/email.html#module-email" title="email: Package supporting the parsing, manipulating, and generating email messages."><code class="xref py py-mod docutils literal notranslate"><span class="pre">email</span></code></a> has a new submodule, <a class="reference internal" href="../library/email.contentmanager.html#module-email.contentmanager" title="email.contentmanager: Storing and Retrieving Content from MIME Parts"><code class="xref py py-mod docutils literal notranslate"><span class="pre">contentmanager</span></code></a>, and
a new <a class="reference internal" href="../library/email.compat32-message.html#email.message.Message" title="email.message.Message"><code class="xref py py-mod docutils literal notranslate"><span class="pre">Message</span></code></a> subclass
(<code class="xref py py-class docutils literal notranslate"><span class="pre">EmailMessage</span></code>) that <a class="reference internal" href="#whatsnew-email-contentmanager"><span class="std std-ref">simplify MIME
handling</span></a> (<a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=18891">bpo-18891</a>).</p></li>
<li><p>The <a class="reference internal" href="../library/inspect.html#module-inspect" title="inspect: Extract information and source code from live objects."><code class="xref py py-mod docutils literal notranslate"><span class="pre">inspect</span></code></a> and <a class="reference internal" href="../library/pydoc.html#module-pydoc" title="pydoc: Documentation generator and online help system."><code class="xref py py-mod docutils literal notranslate"><span class="pre">pydoc</span></code></a> modules are now capable of
correct introspection of a much wider variety of callable objects,
which improves the output of the Python <a class="reference internal" href="../library/functions.html#help" title="help"><code class="xref py py-func docutils literal notranslate"><span class="pre">help()</span></code></a> system.</p></li>
<li><p>The <a class="reference internal" href="../library/ipaddress.html#module-ipaddress" title="ipaddress: IPv4/IPv6 manipulation library."><code class="xref py py-mod docutils literal notranslate"><span class="pre">ipaddress</span></code></a> module API has been declared stable</p></li>
</ul>
<p>Security improvements:</p>
<ul class="simple">
<li><p><a class="reference internal" href="#whatsnew-pep-456"><span class="std std-ref">Secure and interchangeable hash algorithm</span></a>
(<span class="target" id="index-13"></span><a class="pep reference external" href="https://peps.python.org/pep-0456/"><strong>PEP 456</strong></a>).</p></li>
<li><p><a class="reference internal" href="#whatsnew-pep-446"><span class="std std-ref">Make newly created file descriptors non-inheritable</span></a>
(<span class="target" id="index-14"></span><a class="pep reference external" href="https://peps.python.org/pep-0446/"><strong>PEP 446</strong></a>) to avoid leaking file descriptors to child processes.</p></li>
<li><p>New command line option for <a class="reference internal" href="#whatsnew-isolated-mode"><span class="std std-ref">isolated mode</span></a>,
(<a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=16499">bpo-16499</a>).</p></li>
<li><p><a class="reference internal" href="../library/multiprocessing.html#module-multiprocessing" title="multiprocessing: Process-based parallelism."><code class="xref py py-mod docutils literal notranslate"><span class="pre">multiprocessing</span></code></a> now has <a class="reference internal" href="#whatsnew-multiprocessing-no-fork"><span class="std std-ref">an option to avoid using os.fork
on Unix</span></a>. <em>spawn</em> and <em>forkserver</em> are
more secure because they avoid sharing data with child processes.</p></li>
<li><p><a class="reference internal" href="../library/multiprocessing.html#module-multiprocessing" title="multiprocessing: Process-based parallelism."><code class="xref py py-mod docutils literal notranslate"><span class="pre">multiprocessing</span></code></a> child processes on Windows no longer inherit
all of the parent’s inheritable handles, only the necessary ones.</p></li>
<li><p>A new <a class="reference internal" href="../library/hashlib.html#hashlib.pbkdf2_hmac" title="hashlib.pbkdf2_hmac"><code class="xref py py-func docutils literal notranslate"><span class="pre">hashlib.pbkdf2_hmac()</span></code></a> function provides
the <a class="reference external" href="https://en.wikipedia.org/wiki/PBKDF2">PKCS#5 password-based key derivation function 2</a>.</p></li>
<li><p><a class="reference internal" href="#whatsnew-tls-11-12"><span class="std std-ref">TLSv1.1 and TLSv1.2 support</span></a> for <a class="reference internal" href="../library/ssl.html#module-ssl" title="ssl: TLS/SSL wrapper for socket objects"><code class="xref py py-mod docutils literal notranslate"><span class="pre">ssl</span></code></a>.</p></li>
<li><p><a class="reference internal" href="#whatsnew34-win-cert-store"><span class="std std-ref">Retrieving certificates from the Windows system cert store support</span></a> for <a class="reference internal" href="../library/ssl.html#module-ssl" title="ssl: TLS/SSL wrapper for socket objects"><code class="xref py py-mod docutils literal notranslate"><span class="pre">ssl</span></code></a>.</p></li>
<li><p><a class="reference internal" href="#whatsnew34-sni"><span class="std std-ref">Server-side SNI (Server Name Indication) support</span></a> for <a class="reference internal" href="../library/ssl.html#module-ssl" title="ssl: TLS/SSL wrapper for socket objects"><code class="xref py py-mod docutils literal notranslate"><span class="pre">ssl</span></code></a>.</p></li>
<li><p>The <a class="reference internal" href="../library/ssl.html#ssl.SSLContext" title="ssl.SSLContext"><code class="xref py py-class docutils literal notranslate"><span class="pre">ssl.SSLContext</span></code></a> class has a <a class="reference internal" href="#whatsnew34-sslcontext"><span class="std std-ref">lot of improvements</span></a>.</p></li>
<li><p>All modules in the standard library that support SSL now support server
certificate verification, including hostname matching
(<a class="reference internal" href="../library/ssl.html#ssl.match_hostname" title="ssl.match_hostname"><code class="xref py py-func docutils literal notranslate"><span class="pre">ssl.match_hostname()</span></code></a>) and CRLs (Certificate Revocation lists, see
<a class="reference internal" href="../library/ssl.html#ssl.SSLContext.load_verify_locations" title="ssl.SSLContext.load_verify_locations"><code class="xref py py-func docutils literal notranslate"><span class="pre">ssl.SSLContext.load_verify_locations()</span></code></a>).</p></li>
</ul>
<p>CPython implementation improvements:</p>
<ul class="simple">
<li><p><a class="reference internal" href="#whatsnew-pep-442"><span class="std std-ref">Safe object finalization</span></a> (<span class="target" id="index-15"></span><a class="pep reference external" href="https://peps.python.org/pep-0442/"><strong>PEP 442</strong></a>).</p></li>
<li><p>Leveraging <span class="target" id="index-16"></span><a class="pep reference external" href="https://peps.python.org/pep-0442/"><strong>PEP 442</strong></a>, in most cases <a class="reference internal" href="#whatsnew-pep-442"><span class="std std-ref">module globals are no longer set
to None during finalization</span></a> (<a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=18214">bpo-18214</a>).</p></li>
<li><p><a class="reference internal" href="#whatsnew-pep-445"><span class="std std-ref">Configurable memory allocators</span></a> (<span class="target" id="index-17"></span><a class="pep reference external" href="https://peps.python.org/pep-0445/"><strong>PEP 445</strong></a>).</p></li>
<li><p><a class="reference internal" href="#whatsnew-pep-436"><span class="std std-ref">Argument Clinic</span></a> (<span class="target" id="index-18"></span><a class="pep reference external" href="https://peps.python.org/pep-0436/"><strong>PEP 436</strong></a>).</p></li>
</ul>
<p>Please read on for a comprehensive list of user-facing changes, including many
other smaller improvements, CPython optimizations, deprecations, and potential
porting issues.</p>
</section>
<section id="new-features">
<h2>New Features<a class="headerlink" href="#new-features" title="Permalink to this heading">¶</a></h2>
<section id="pep-453-explicit-bootstrapping-of-pip-in-python-installations">
<span id="whatsnew-pep-453"></span><h3>PEP 453: Explicit Bootstrapping of PIP in Python Installations<a class="headerlink" href="#pep-453-explicit-bootstrapping-of-pip-in-python-installations" title="Permalink to this heading">¶</a></h3>
<section id="bootstrapping-pip-by-default">
<h4>Bootstrapping pip By Default<a class="headerlink" href="#bootstrapping-pip-by-default" title="Permalink to this heading">¶</a></h4>
<p>The new <a class="reference internal" href="../library/ensurepip.html#module-ensurepip" title="ensurepip: Bootstrapping the "pip" installer into an existing Python installation or virtual environment."><code class="xref py py-mod docutils literal notranslate"><span class="pre">ensurepip</span></code></a> module (defined in <span class="target" id="index-19"></span><a class="pep reference external" href="https://peps.python.org/pep-0453/"><strong>PEP 453</strong></a>) provides a standard
cross-platform mechanism to bootstrap the pip installer into Python
installations and virtual environments. The version of <code class="docutils literal notranslate"><span class="pre">pip</span></code> included
with Python 3.4.0 is <code class="docutils literal notranslate"><span class="pre">pip</span></code> 1.5.4, and future 3.4.x maintenance releases
will update the bundled version to the latest version of <code class="docutils literal notranslate"><span class="pre">pip</span></code> that is
available at the time of creating the release candidate.</p>
<p>By default, the commands <code class="docutils literal notranslate"><span class="pre">pipX</span></code> and <code class="docutils literal notranslate"><span class="pre">pipX.Y</span></code> will be installed on all
platforms (where X.Y stands for the version of the Python installation),
along with the <code class="docutils literal notranslate"><span class="pre">pip</span></code> Python package and its dependencies. On Windows and
in virtual environments on all platforms, the unversioned <code class="docutils literal notranslate"><span class="pre">pip</span></code> command
will also be installed. On other platforms, the system wide unversioned
<code class="docutils literal notranslate"><span class="pre">pip</span></code> command typically refers to the separately installed Python 2
version.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">pyvenv</span></code> command line utility and the <a class="reference internal" href="../library/venv.html#module-venv" title="venv: Creation of virtual environments."><code class="xref py py-mod docutils literal notranslate"><span class="pre">venv</span></code></a>
module make use of the <a class="reference internal" href="../library/ensurepip.html#module-ensurepip" title="ensurepip: Bootstrapping the "pip" installer into an existing Python installation or virtual environment."><code class="xref py py-mod docutils literal notranslate"><span class="pre">ensurepip</span></code></a> module to make <code class="docutils literal notranslate"><span class="pre">pip</span></code> readily
available in virtual environments. When using the command line utility,
<code class="docutils literal notranslate"><span class="pre">pip</span></code> is installed by default, while when using the <a class="reference internal" href="../library/venv.html#module-venv" title="venv: Creation of virtual environments."><code class="xref py py-mod docutils literal notranslate"><span class="pre">venv</span></code></a> module
<a class="reference internal" href="../library/venv.html#venv-api"><span class="std std-ref">API</span></a> installation of <code class="docutils literal notranslate"><span class="pre">pip</span></code> must be requested explicitly.</p>
<p>For CPython <a class="reference internal" href="../using/unix.html#building-python-on-unix"><span class="std std-ref">source builds on POSIX systems</span></a>,
the <code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">install</span></code> and <code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">altinstall</span></code> commands bootstrap <code class="docutils literal notranslate"><span class="pre">pip</span></code> by
default. This behaviour can be controlled through configure options, and
overridden through Makefile options.</p>
<p>On Windows and Mac OS X, the CPython installers now default to installing
<code class="docutils literal notranslate"><span class="pre">pip</span></code> along with CPython itself (users may opt out of installing it
during the installation process). Window users will need to opt in to the
automatic <code class="docutils literal notranslate"><span class="pre">PATH</span></code> modifications to have <code class="docutils literal notranslate"><span class="pre">pip</span></code> available from the command
line by default, otherwise it can still be accessed through the Python
launcher for Windows as <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">-m</span> <span class="pre">pip</span></code>.</p>
<p>As <a class="reference external" href="https://peps.python.org/pep-0453/#recommendations-for-downstream-distributors">discussed in the PEP</a>, platform packagers may choose not to install
these commands by default, as long as, when invoked, they provide clear and
simple directions on how to install them on that platform (usually using
the system package manager).</p>
<div class="admonition note">
<p class="admonition-title">Not</p>
<p>To avoid conflicts between parallel Python 2 and Python 3 installations,
only the versioned <code class="docutils literal notranslate"><span class="pre">pip3</span></code> and <code class="docutils literal notranslate"><span class="pre">pip3.4</span></code> commands are bootstrapped by
default when <code class="docutils literal notranslate"><span class="pre">ensurepip</span></code> is invoked directly - the <code class="docutils literal notranslate"><span class="pre">--default-pip</span></code>
option is needed to also request the unversioned <code class="docutils literal notranslate"><span class="pre">pip</span></code> command.
<code class="docutils literal notranslate"><span class="pre">pyvenv</span></code> and the Windows installer ensure that the unqualified <code class="docutils literal notranslate"><span class="pre">pip</span></code>
command is made available in those environments, and <code class="docutils literal notranslate"><span class="pre">pip</span></code> can always be
invoked via the <code class="docutils literal notranslate"><span class="pre">-m</span></code> switch rather than directly to avoid ambiguity on
systems with multiple Python installations.</p>
</div>
</section>
<section id="documentation-changes">
<h4>Documentation Changes<a class="headerlink" href="#documentation-changes" title="Permalink to this heading">¶</a></h4>
<p>As part of this change, the <a class="reference internal" href="../installing/index.html#installing-index"><span class="std std-ref">Python Modüllerini Kurmak</span></a> and
<a class="reference internal" href="../distributing/index.html#distributing-index"><span class="std std-ref">Python Modüllerini Dağıtma</span></a> sections of the documentation have been
completely redesigned as short getting started and FAQ documents. Most
packaging documentation has now been moved out to the Python Packaging
Authority maintained <a class="reference external" href="https://packaging.python.org">Python Packaging User Guide</a> and the documentation of the individual
projects.</p>
<p>However, as this migration is currently still incomplete, the legacy
versions of those guides remaining available as <a class="reference internal" href="../install/index.html#install-index"><span class="std std-ref">Python Modüllerini Yükleme (Eski sürüm)</span></a>
and <a class="reference internal" href="../distutils/index.html#distutils-index"><span class="std std-ref">Python Modüllerini Dağıtma (Eski sürüm)</span></a>.</p>
<div class="admonition seealso">
<p class="admonition-title">Ayrıca bakınız</p>
<dl class="simple">
<dt><span class="target" id="index-20"></span><a class="pep reference external" href="https://peps.python.org/pep-0453/"><strong>PEP 453</strong></a> – Explicit bootstrapping of pip in Python installations</dt><dd><p>PEP written by Donald Stufft and Nick Coghlan, implemented by
Donald Stufft, Nick Coghlan, Martin von Löwis and Ned Deily.</p>
</dd>
</dl>
</div>
</section>
</section>
<section id="pep-446-newly-created-file-descriptors-are-non-inheritable">
<span id="whatsnew-pep-446"></span><h3>PEP 446: Newly Created File Descriptors Are Non-Inheritable<a class="headerlink" href="#pep-446-newly-created-file-descriptors-are-non-inheritable" title="Permalink to this heading">¶</a></h3>
<p><span class="target" id="index-21"></span><a class="pep reference external" href="https://peps.python.org/pep-0446/"><strong>PEP 446</strong></a> makes newly created file descriptors <a class="reference internal" href="../library/os.html#fd-inheritance"><span class="std std-ref">non-inheritable</span></a>. In general, this is the behavior an application will
want: when launching a new process, having currently open files also
open in the new process can lead to all sorts of hard to find bugs,
and potentially to security issues.</p>
<p>However, there are occasions when inheritance is desired. To support
these cases, the following new functions and methods are available:</p>
<ul class="simple">
<li><p><a class="reference internal" href="../library/os.html#os.get_inheritable" title="os.get_inheritable"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.get_inheritable()</span></code></a>, <a class="reference internal" href="../library/os.html#os.set_inheritable" title="os.set_inheritable"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.set_inheritable()</span></code></a></p></li>
<li><p><a class="reference internal" href="../library/os.html#os.get_handle_inheritable" title="os.get_handle_inheritable"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.get_handle_inheritable()</span></code></a>, <a class="reference internal" href="../library/os.html#os.set_handle_inheritable" title="os.set_handle_inheritable"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.set_handle_inheritable()</span></code></a></p></li>
<li><p><a class="reference internal" href="../library/socket.html#socket.socket.get_inheritable" title="socket.socket.get_inheritable"><code class="xref py py-meth docutils literal notranslate"><span class="pre">socket.socket.get_inheritable()</span></code></a>, <a class="reference internal" href="../library/socket.html#socket.socket.set_inheritable" title="socket.socket.set_inheritable"><code class="xref py py-meth docutils literal notranslate"><span class="pre">socket.socket.set_inheritable()</span></code></a></p></li>
</ul>
<div class="admonition seealso">
<p class="admonition-title">Ayrıca bakınız</p>
<dl class="simple">
<dt><span class="target" id="index-22"></span><a class="pep reference external" href="https://peps.python.org/pep-0446/"><strong>PEP 446</strong></a> – Make newly created file descriptors non-inheritable</dt><dd><p>PEP written and implemented by Victor Stinner.</p>
</dd>
</dl>
</div>
</section>
<section id="improvements-to-codec-handling">
<span id="codec-handling-improvements"></span><h3>Improvements to Codec Handling<a class="headerlink" href="#improvements-to-codec-handling" title="Permalink to this heading">¶</a></h3>
<p>Since it was first introduced, the <a class="reference internal" href="../library/codecs.html#module-codecs" title="codecs: Encode and decode data and streams."><code class="xref py py-mod docutils literal notranslate"><span class="pre">codecs</span></code></a> module has always been
intended to operate as a type-neutral dynamic encoding and decoding
system. However, its close coupling with the Python text model, especially
the type restricted convenience methods on the builtin <a class="reference internal" href="../library/stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a>,
<a class="reference internal" href="../library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> and <a class="reference internal" href="../library/stdtypes.html#bytearray" title="bytearray"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytearray</span></code></a> types, has historically obscured that
fact.</p>
<p>As a key step in clarifying the situation, the <a class="reference internal" href="../library/codecs.html#codecs.encode" title="codecs.encode"><code class="xref py py-meth docutils literal notranslate"><span class="pre">codecs.encode()</span></code></a> and
<a class="reference internal" href="../library/codecs.html#codecs.decode" title="codecs.decode"><code class="xref py py-meth docutils literal notranslate"><span class="pre">codecs.decode()</span></code></a> convenience functions are now properly documented in
Python 2.7, 3.3 and 3.4. These functions have existed in the <a class="reference internal" href="../library/codecs.html#module-codecs" title="codecs: Encode and decode data and streams."><code class="xref py py-mod docutils literal notranslate"><span class="pre">codecs</span></code></a>
module (and have been covered by the regression test suite) since Python 2.4,
but were previously only discoverable through runtime introspection.</p>
<p>Unlike the convenience methods on <a class="reference internal" href="../library/stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a>, <a class="reference internal" href="../library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> and
<a class="reference internal" href="../library/stdtypes.html#bytearray" title="bytearray"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytearray</span></code></a>, the <a class="reference internal" href="../library/codecs.html#module-codecs" title="codecs: Encode and decode data and streams."><code class="xref py py-mod docutils literal notranslate"><span class="pre">codecs</span></code></a> convenience functions support arbitrary
codecs in both Python 2 and Python 3, rather than being limited to Unicode text
encodings (in Python 3) or <code class="docutils literal notranslate"><span class="pre">basestring</span></code> <-> <code class="docutils literal notranslate"><span class="pre">basestring</span></code> conversions (in
Python 2).</p>
<p>In Python 3.4, the interpreter is able to identify the known non-text
encodings provided in the standard library and direct users towards these
general purpose convenience functions when appropriate:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="sa">b</span><span class="s2">"abcdef"</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s2">"hex"</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
File <span class="nb">"<stdin>"</span>, line <span class="m">1</span>, in <span class="n"><module></span>
<span class="gr">LookupError</span>: <span class="n">'hex' is not a text encoding; use codecs.decode() to handle arbitrary codecs</span>
<span class="gp">>>> </span><span class="s2">"hello"</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="s2">"rot13"</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
File <span class="nb">"<stdin>"</span>, line <span class="m">1</span>, in <span class="n"><module></span>
<span class="gr">LookupError</span>: <span class="n">'rot13' is not a text encoding; use codecs.encode() to handle arbitrary codecs</span>
<span class="gp">>>> </span><span class="nb">open</span><span class="p">(</span><span class="s2">"foo.txt"</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">"hex"</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
File <span class="nb">"<stdin>"</span>, line <span class="m">1</span>, in <span class="n"><module></span>
<span class="gr">LookupError</span>: <span class="n">'hex' is not a text encoding; use codecs.open() to handle arbitrary codecs</span>
</pre></div>
</div>
<p>In a related change, whenever it is feasible without breaking backwards
compatibility, exceptions raised during encoding and decoding operations
are wrapped in a chained exception of the same type that mentions the
name of the codec responsible for producing the error:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">codecs</span>
<span class="gp">>>> </span><span class="n">codecs</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="sa">b</span><span class="s2">"abcdefgh"</span><span class="p">,</span> <span class="s2">"hex"</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
File <span class="nb">"/usr/lib/python3.4/encodings/hex_codec.py"</span>, line <span class="m">20</span>, in <span class="n">hex_decode</span>
<span class="w"> </span><span class="k">return</span> <span class="p">(</span><span class="n">binascii</span><span class="o">.</span><span class="n">a2b_hex</span><span class="p">(</span><span class="nb">input</span><span class="p">),</span> <span class="nb">len</span><span class="p">(</span><span class="nb">input</span><span class="p">))</span>
<span class="gr">binascii.Error</span>: <span class="n">Non-hexadecimal digit found</span>
<span class="gt">The above exception was the direct cause of the following exception:</span>
<span class="gt">Traceback (most recent call last):</span>
File <span class="nb">"<stdin>"</span>, line <span class="m">1</span>, in <span class="n"><module></span>
<span class="gr">binascii.Error</span>: <span class="n">decoding with 'hex' codec failed (Error: Non-hexadecimal digit found)</span>
<span class="gp">>>> </span><span class="n">codecs</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="s2">"hello"</span><span class="p">,</span> <span class="s2">"bz2"</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
File <span class="nb">"/usr/lib/python3.4/encodings/bz2_codec.py"</span>, line <span class="m">17</span>, in <span class="n">bz2_encode</span>
<span class="w"> </span><span class="k">return</span> <span class="p">(</span><span class="n">bz2</span><span class="o">.</span><span class="n">compress</span><span class="p">(</span><span class="nb">input</span><span class="p">),</span> <span class="nb">len</span><span class="p">(</span><span class="nb">input</span><span class="p">))</span>
File <span class="nb">"/usr/lib/python3.4/bz2.py"</span>, line <span class="m">498</span>, in <span class="n">compress</span>
<span class="w"> </span><span class="k">return</span> <span class="n">comp</span><span class="o">.</span><span class="n">compress</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="o">+</span> <span class="n">comp</span><span class="o">.</span><span class="n">flush</span><span class="p">()</span>
<span class="gr">TypeError</span>: <span class="n">'str' does not support the buffer interface</span>
<span class="gt">The above exception was the direct cause of the following exception:</span>
<span class="gt">Traceback (most recent call last):</span>
File <span class="nb">"<stdin>"</span>, line <span class="m">1</span>, in <span class="n"><module></span>
<span class="gr">TypeError</span>: <span class="n">encoding with 'bz2' codec failed (TypeError: 'str' does not support the buffer interface)</span>
</pre></div>
</div>
<p>Finally, as the examples above show, these improvements have permitted
the restoration of the convenience aliases for the non-Unicode codecs that
were themselves restored in Python 3.2. This means that encoding binary data
to and from its hexadecimal representation (for example) can now be written
as:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">codecs</span> <span class="kn">import</span> <span class="n">encode</span><span class="p">,</span> <span class="n">decode</span>
<span class="gp">>>> </span><span class="n">encode</span><span class="p">(</span><span class="sa">b</span><span class="s2">"hello"</span><span class="p">,</span> <span class="s2">"hex"</span><span class="p">)</span>
<span class="go">b'68656c6c6f'</span>
<span class="gp">>>> </span><span class="n">decode</span><span class="p">(</span><span class="sa">b</span><span class="s2">"68656c6c6f"</span><span class="p">,</span> <span class="s2">"hex"</span><span class="p">)</span>
<span class="go">b'hello'</span>
</pre></div>
</div>
<p>The binary and text transforms provided in the standard library are detailed
in <a class="reference internal" href="../library/codecs.html#binary-transforms"><span class="std std-ref">Binary Transforms</span></a> and <a class="reference internal" href="../library/codecs.html#text-transforms"><span class="std std-ref">Text Transforms</span></a>.</p>
<p>(Contributed by Nick Coghlan in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=7475">bpo-7475</a>, <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=17827">bpo-17827</a>,
<a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=17828">bpo-17828</a> and <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=19619">bpo-19619</a>.)</p>
</section>
<section id="pep-451-a-modulespec-type-for-the-import-system">
<span id="whatsnew-pep-451"></span><h3>PEP 451: A ModuleSpec Type for the Import System<a class="headerlink" href="#pep-451-a-modulespec-type-for-the-import-system" title="Permalink to this heading">¶</a></h3>
<p><span class="target" id="index-23"></span><a class="pep reference external" href="https://peps.python.org/pep-0451/"><strong>PEP 451</strong></a> provides an encapsulation of the information about a module that the
import machinery will use to load it (that is, a module specification). This
helps simplify both the import implementation and several import-related APIs.
The change is also a stepping stone for <a class="reference external" href="https://mail.python.org/pipermail/python-dev/2013-November/130111.html">several future import-related
improvements</a>.</p>
<p>The public-facing changes from the PEP are entirely backward-compatible.
Furthermore, they should be transparent to everyone but importer authors. Key
finder and loader methods have been deprecated, but they will continue working.
New importers should use the new methods described in the PEP. Existing
importers should be updated to implement the new methods. See the
<a class="reference internal" href="#deprecated-3-4"><span class="std std-ref">Deprecated</span></a> section for a list of methods that should be replaced and
their replacements.</p>
</section>
<section id="other-language-changes">
<h3>Other Language Changes<a class="headerlink" href="#other-language-changes" title="Permalink to this heading">¶</a></h3>
<p>Some smaller changes made to the core Python language are:</p>
<ul class="simple">
<li><p>Unicode database updated to UCD version 6.3.</p></li>
<li><p><a class="reference internal" href="../library/functions.html#min" title="min"><code class="xref py py-func docutils literal notranslate"><span class="pre">min()</span></code></a> and <a class="reference internal" href="../library/functions.html#max" title="max"><code class="xref py py-func docutils literal notranslate"><span class="pre">max()</span></code></a> now accept a <em>default</em> keyword-only argument that
can be used to specify the value they return if the iterable they are
evaluating has no elements. (Contributed by Julian Berman in
<a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=18111">bpo-18111</a>.)</p></li>
<li><p>Module objects are now <a class="reference internal" href="../library/weakref.html#mod-weakref"><span class="std std-ref">weakly referenceable</span></a>.</p></li>
<li><p>Module <code class="docutils literal notranslate"><span class="pre">__file__</span></code> attributes (and related values) should now always
contain absolute paths by default, with the sole exception of
<code class="docutils literal notranslate"><span class="pre">__main__.__file__</span></code> when a script has been executed directly using
a relative path. (Contributed by Brett Cannon in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=18416">bpo-18416</a>.)</p></li>
<li><p>All the UTF-* codecs (except UTF-7) now reject surrogates during both
encoding and decoding unless the <code class="docutils literal notranslate"><span class="pre">surrogatepass</span></code> error handler is used,
with the exception of the UTF-16 decoder (which accepts valid surrogate pairs)
and the UTF-16 encoder (which produces them while encoding non-BMP characters).
(Contributed by Victor Stinner, Kang-Hao (Kenny) Lu and Serhiy Storchaka in
<a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=12892">bpo-12892</a>.)</p></li>
<li><p>New German EBCDIC <a class="reference internal" href="../library/codecs.html#standard-encodings"><span class="std std-ref">codec</span></a> <code class="docutils literal notranslate"><span class="pre">cp273</span></code>. (Contributed
by Michael Bierenfeld and Andrew Kuchling in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=1097797">bpo-1097797</a>.)</p></li>
<li><p>New Ukrainian <a class="reference internal" href="../library/codecs.html#standard-encodings"><span class="std std-ref">codec</span></a> <code class="docutils literal notranslate"><span class="pre">cp1125</span></code>. (Contributed by
Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=19668">bpo-19668</a>.)</p></li>
<li><p><a class="reference internal" href="../library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a>.join() and <a class="reference internal" href="../library/stdtypes.html#bytearray" title="bytearray"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytearray</span></code></a>.join() now accept arbitrary
buffer objects as arguments. (Contributed by Antoine Pitrou in
<a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=15958">bpo-15958</a>.)</p></li>
<li><p>The <a class="reference internal" href="../library/functions.html#int" title="int"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a> constructor now accepts any object that has an <code class="docutils literal notranslate"><span class="pre">__index__</span></code>
method for its <em>base</em> argument. (Contributed by Mark Dickinson in
<a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=16772">bpo-16772</a>.)</p></li>
<li><p>Frame objects now have a <a class="reference internal" href="../reference/datamodel.html#frame.clear" title="frame.clear"><code class="xref py py-func docutils literal notranslate"><span class="pre">clear()</span></code></a> method that clears all
references to local variables from the frame. (Contributed by Antoine Pitrou
in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=17934">bpo-17934</a>.)</p></li>
<li><p><a class="reference internal" href="../library/stdtypes.html#memoryview" title="memoryview"><code class="xref py py-class docutils literal notranslate"><span class="pre">memoryview</span></code></a> is now registered as a <a class="reference internal" href="../library/collections.abc.html#module-collections.abc" title="collections.abc: Abstract base classes for containers"><code class="xref py py-class docutils literal notranslate"><span class="pre">Sequence</span></code></a>,
and supports the <a class="reference internal" href="../library/functions.html#reversed" title="reversed"><code class="xref py py-func docutils literal notranslate"><span class="pre">reversed()</span></code></a> builtin. (Contributed by Nick Coghlan
and Claudiu Popa in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=18690">bpo-18690</a> and <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=19078">bpo-19078</a>.)</p></li>
<li><p>Signatures reported by <a class="reference internal" href="../library/functions.html#help" title="help"><code class="xref py py-func docutils literal notranslate"><span class="pre">help()</span></code></a> have been modified and improved in
several cases as a result of the introduction of Argument Clinic and other
changes to the <a class="reference internal" href="../library/inspect.html#module-inspect" title="inspect: Extract information and source code from live objects."><code class="xref py py-mod docutils literal notranslate"><span class="pre">inspect</span></code></a> and <a class="reference internal" href="../library/pydoc.html#module-pydoc" title="pydoc: Documentation generator and online help system."><code class="xref py py-mod docutils literal notranslate"><span class="pre">pydoc</span></code></a> modules.</p></li>
<li><p><a class="reference internal" href="../reference/datamodel.html#object.__length_hint__" title="object.__length_hint__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__length_hint__()</span></code></a> is now part of the formal language
specification (see <span class="target" id="index-24"></span><a class="pep reference external" href="https://peps.python.org/pep-0424/"><strong>PEP 424</strong></a>). (Contributed by Armin Ronacher in
<a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=16148">bpo-16148</a>.)</p></li>
</ul>
</section>
</section>
<section id="new-modules">
<h2>New Modules<a class="headerlink" href="#new-modules" title="Permalink to this heading">¶</a></h2>
<section id="asyncio">
<span id="whatsnew-asyncio"></span><h3>asyncio<a class="headerlink" href="#asyncio" title="Permalink to this heading">¶</a></h3>
<p>The new <a class="reference internal" href="../library/asyncio.html#module-asyncio" title="asyncio: Asynchronous I/O."><code class="xref py py-mod docutils literal notranslate"><span class="pre">asyncio</span></code></a> module (defined in <span class="target" id="index-25"></span><a class="pep reference external" href="https://peps.python.org/pep-3156/"><strong>PEP 3156</strong></a>) provides a standard
pluggable event loop model for Python, providing solid asynchronous IO
support in the standard library, and making it easier for other event loop
implementations to interoperate with the standard library and each other.</p>
<p>For Python 3.4, this module is considered a <a class="reference internal" href="../glossary.html#term-provisional-API"><span class="xref std std-term">provisional API</span></a>.</p>
<div class="admonition seealso">
<p class="admonition-title">Ayrıca bakınız</p>
<dl class="simple">
<dt><span class="target" id="index-26"></span><a class="pep reference external" href="https://peps.python.org/pep-3156/"><strong>PEP 3156</strong></a> – Asynchronous IO Support Rebooted: the “asyncio” Module</dt><dd><p>PEP written and implementation led by Guido van Rossum.</p>
</dd>
</dl>
</div>
</section>
<section id="ensurepip">
<span id="whatsnew-ensurepip"></span><h3>ensurepip<a class="headerlink" href="#ensurepip" title="Permalink to this heading">¶</a></h3>
<p>The new <a class="reference internal" href="../library/ensurepip.html#module-ensurepip" title="ensurepip: Bootstrapping the "pip" installer into an existing Python installation or virtual environment."><code class="xref py py-mod docutils literal notranslate"><span class="pre">ensurepip</span></code></a> module is the primary infrastructure for the
<span class="target" id="index-27"></span><a class="pep reference external" href="https://peps.python.org/pep-0453/"><strong>PEP 453</strong></a> implementation. In the normal course of events end users will not
need to interact with this module, but it can be used to manually bootstrap
<code class="docutils literal notranslate"><span class="pre">pip</span></code> if the automated bootstrapping into an installation or virtual
environment was declined.</p>
<p><a class="reference internal" href="../library/ensurepip.html#module-ensurepip" title="ensurepip: Bootstrapping the "pip" installer into an existing Python installation or virtual environment."><code class="xref py py-mod docutils literal notranslate"><span class="pre">ensurepip</span></code></a> includes a bundled copy of <code class="docutils literal notranslate"><span class="pre">pip</span></code>, up-to-date as of the first
release candidate of the release of CPython with which it ships (this applies
to both maintenance releases and feature releases). <code class="docutils literal notranslate"><span class="pre">ensurepip</span></code> does not
access the internet. If the installation has internet access, after
<code class="docutils literal notranslate"><span class="pre">ensurepip</span></code> is run the bundled <code class="docutils literal notranslate"><span class="pre">pip</span></code> can be used to upgrade <code class="docutils literal notranslate"><span class="pre">pip</span></code> to a
more recent release than the bundled one. (Note that such an upgraded version
of <code class="docutils literal notranslate"><span class="pre">pip</span></code> is considered to be a separately installed package and will not be
removed if Python is uninstalled.)</p>
<p>The module is named <em>ensure</em>pip because if called when <code class="docutils literal notranslate"><span class="pre">pip</span></code> is already
installed, it does nothing. It also has an <code class="docutils literal notranslate"><span class="pre">--upgrade</span></code> option that will
cause it to install the bundled copy of <code class="docutils literal notranslate"><span class="pre">pip</span></code> if the existing installed
version of <code class="docutils literal notranslate"><span class="pre">pip</span></code> is older than the bundled copy.</p>
</section>
<section id="enum">
<span id="whatsnew-enum"></span><h3>enum<a class="headerlink" href="#enum" title="Permalink to this heading">¶</a></h3>
<p>The new <a class="reference internal" href="../library/enum.html#module-enum" title="enum: Implementation of an enumeration class."><code class="xref py py-mod docutils literal notranslate"><span class="pre">enum</span></code></a> module (defined in <span class="target" id="index-28"></span><a class="pep reference external" href="https://peps.python.org/pep-0435/"><strong>PEP 435</strong></a>) provides a standard
implementation of enumeration types, allowing other modules (such as
<a class="reference internal" href="../library/socket.html#module-socket" title="socket: Low-level networking interface."><code class="xref py py-mod docutils literal notranslate"><span class="pre">socket</span></code></a>) to provide more informative error messages and better
debugging support by replacing opaque integer constants with backwards
compatible enumeration values.</p>
<div class="admonition seealso">
<p class="admonition-title">Ayrıca bakınız</p>
<dl class="simple">
<dt><span class="target" id="index-29"></span><a class="pep reference external" href="https://peps.python.org/pep-0435/"><strong>PEP 435</strong></a> – Adding an Enum type to the Python standard library</dt><dd><p>PEP written by Barry Warsaw, Eli Bendersky and Ethan Furman,
implemented by Ethan Furman.</p>
</dd>
</dl>
</div>
</section>
<section id="pathlib">
<span id="whatsnew-pathlib"></span><h3>pathlib<a class="headerlink" href="#pathlib" title="Permalink to this heading">¶</a></h3>
<p>The new <a class="reference internal" href="../library/pathlib.html#module-pathlib" title="pathlib: Object-oriented filesystem paths"><code class="xref py py-mod docutils literal notranslate"><span class="pre">pathlib</span></code></a> module offers classes representing filesystem paths
with semantics appropriate for different operating systems. Path classes are
divided between <em>pure paths</em>, which provide purely computational operations
without I/O, and <em>concrete paths</em>, which inherit from pure paths but also
provide I/O operations.</p>
<p>For Python 3.4, this module is considered a <a class="reference internal" href="../glossary.html#term-provisional-API"><span class="xref std std-term">provisional API</span></a>.</p>
<div class="admonition seealso">
<p class="admonition-title">Ayrıca bakınız</p>
<dl class="simple">
<dt><span class="target" id="index-30"></span><a class="pep reference external" href="https://peps.python.org/pep-0428/"><strong>PEP 428</strong></a> – The pathlib module – object-oriented filesystem paths</dt><dd><p>PEP written and implemented by Antoine Pitrou.</p>
</dd>
</dl>
</div>
</section>
<section id="selectors">
<span id="whatsnew-selectors"></span><h3>selectors<a class="headerlink" href="#selectors" title="Permalink to this heading">¶</a></h3>
<p>The new <a class="reference internal" href="../library/selectors.html#module-selectors" title="selectors: High-level I/O multiplexing."><code class="xref py py-mod docutils literal notranslate"><span class="pre">selectors</span></code></a> module (created as part of implementing <span class="target" id="index-31"></span><a class="pep reference external" href="https://peps.python.org/pep-3156/"><strong>PEP 3156</strong></a>)
allows high-level and efficient I/O multiplexing, built upon the
<a class="reference internal" href="../library/select.html#module-select" title="select: Wait for I/O completion on multiple streams."><code class="xref py py-mod docutils literal notranslate"><span class="pre">select</span></code></a> module primitives.</p>
</section>
<section id="statistics">
<span id="whatsnew-statistics"></span><h3>statistics<a class="headerlink" href="#statistics" title="Permalink to this heading">¶</a></h3>
<p>The new <a class="reference internal" href="../library/statistics.html#module-statistics" title="statistics: Mathematical statistics functions"><code class="xref py py-mod docutils literal notranslate"><span class="pre">statistics</span></code></a> module (defined in <span class="target" id="index-32"></span><a class="pep reference external" href="https://peps.python.org/pep-0450/"><strong>PEP 450</strong></a>) offers some core
statistics functionality directly in the standard library. This module
supports calculation of the mean, median, mode, variance and standard
deviation of a data series.</p>
<div class="admonition seealso">
<p class="admonition-title">Ayrıca bakınız</p>
<dl class="simple">
<dt><span class="target" id="index-33"></span><a class="pep reference external" href="https://peps.python.org/pep-0450/"><strong>PEP 450</strong></a> – Adding A Statistics Module To The Standard Library</dt><dd><p>PEP written and implemented by Steven D’Aprano</p>
</dd>
</dl>
</div>
</section>
<section id="tracemalloc">
<span id="whatsnew-tracemalloc"></span><h3>tracemalloc<a class="headerlink" href="#tracemalloc" title="Permalink to this heading">¶</a></h3>
<p>The new <a class="reference internal" href="../library/tracemalloc.html#module-tracemalloc" title="tracemalloc: Trace memory allocations."><code class="xref py py-mod docutils literal notranslate"><span class="pre">tracemalloc</span></code></a> module (defined in <span class="target" id="index-34"></span><a class="pep reference external" href="https://peps.python.org/pep-0454/"><strong>PEP 454</strong></a>) is a debug tool to
trace memory blocks allocated by Python. It provides the following information:</p>
<ul class="simple">
<li><p>Trace where an object was allocated</p></li>
<li><p>Statistics on allocated memory blocks per filename and per line number:
total size, number and average size of allocated memory blocks</p></li>
<li><p>Compute the differences between two snapshots to detect memory leaks</p></li>
</ul>
<div class="admonition seealso">
<p class="admonition-title">Ayrıca bakınız</p>
<dl class="simple">
<dt><span class="target" id="index-35"></span><a class="pep reference external" href="https://peps.python.org/pep-0454/"><strong>PEP 454</strong></a> – Add a new tracemalloc module to trace Python memory allocations</dt><dd><p>PEP written and implemented by Victor Stinner</p>
</dd>
</dl>
</div>
</section>
</section>
<section id="improved-modules">
<h2>Improved Modules<a class="headerlink" href="#improved-modules" title="Permalink to this heading">¶</a></h2>
<section id="abc">
<h3>abc<a class="headerlink" href="#abc" title="Permalink to this heading">¶</a></h3>
<p>New function <a class="reference internal" href="../library/abc.html#abc.get_cache_token" title="abc.get_cache_token"><code class="xref py py-func docutils literal notranslate"><span class="pre">abc.get_cache_token()</span></code></a> can be used to know when to invalidate
caches that are affected by changes in the object graph. (Contributed
by Łukasz Langa in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=16832">bpo-16832</a>.)</p>
<p>New class <a class="reference internal" href="../library/abc.html#abc.ABC" title="abc.ABC"><code class="xref py py-class docutils literal notranslate"><span class="pre">ABC</span></code></a> has <a class="reference internal" href="../library/abc.html#abc.ABCMeta" title="abc.ABCMeta"><code class="xref py py-class docutils literal notranslate"><span class="pre">ABCMeta</span></code></a> as its meta class.
Using <code class="docutils literal notranslate"><span class="pre">ABC</span></code> as a base class has essentially the same effect as specifying
<code class="docutils literal notranslate"><span class="pre">metaclass=abc.ABCMeta</span></code>, but is simpler to type and easier to read.
(Contributed by Bruno Dupuis in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=16049">bpo-16049</a>.)</p>
</section>
<section id="aifc">
<h3>aifc<a class="headerlink" href="#aifc" title="Permalink to this heading">¶</a></h3>
<p>The <a class="reference internal" href="../library/aifc.html#aifc.aifc.getparams" title="aifc.aifc.getparams"><code class="xref py py-meth docutils literal notranslate"><span class="pre">getparams()</span></code></a> method now returns a namedtuple rather than a
plain tuple. (Contributed by Claudiu Popa in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=17818">bpo-17818</a>.)</p>
<p><a class="reference internal" href="../library/aifc.html#aifc.open" title="aifc.open"><code class="xref py py-func docutils literal notranslate"><span class="pre">aifc.open()</span></code></a> now supports the context management protocol: when used in a
<a class="reference internal" href="../reference/compound_stmts.html#with"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">with</span></code></a> block, the <a class="reference internal" href="../library/aifc.html#aifc.aifc.close" title="aifc.aifc.close"><code class="xref py py-meth docutils literal notranslate"><span class="pre">close()</span></code></a> method of the returned
object will be called automatically at the end of the block. (Contributed by
Serhiy Storchacha in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=16486">bpo-16486</a>.)</p>
<p>The <a class="reference internal" href="../library/aifc.html#aifc.aifc.writeframesraw" title="aifc.aifc.writeframesraw"><code class="xref py py-meth docutils literal notranslate"><span class="pre">writeframesraw()</span></code></a> and <a class="reference internal" href="../library/aifc.html#aifc.aifc.writeframes" title="aifc.aifc.writeframes"><code class="xref py py-meth docutils literal notranslate"><span class="pre">writeframes()</span></code></a>
methods now accept any <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like object</span></a>. (Contributed by Serhiy
Storchaka in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=8311">bpo-8311</a>.)</p>
</section>
<section id="argparse">
<h3>argparse<a class="headerlink" href="#argparse" title="Permalink to this heading">¶</a></h3>
<p>The <a class="reference internal" href="../library/argparse.html#argparse.FileType" title="argparse.FileType"><code class="xref py py-class docutils literal notranslate"><span class="pre">FileType</span></code></a> class now accepts <em>encoding</em> and
<em>errors</em> arguments, which are passed through to <a class="reference internal" href="../library/functions.html#open" title="open"><code class="xref py py-func docutils literal notranslate"><span class="pre">open()</span></code></a>. (Contributed
by Lucas Maystre in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=11175">bpo-11175</a>.)</p>
</section>
<section id="audioop">
<h3>audioop<a class="headerlink" href="#audioop" title="Permalink to this heading">¶</a></h3>
<p><a class="reference internal" href="../library/audioop.html#module-audioop" title="audioop: Manipulate raw audio data. (kullanım dışı)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">audioop</span></code></a> now supports 24-bit samples. (Contributed by Serhiy Storchaka
in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=12866">bpo-12866</a>.)</p>
<p>New <a class="reference internal" href="../library/audioop.html#audioop.byteswap" title="audioop.byteswap"><code class="xref py py-func docutils literal notranslate"><span class="pre">byteswap()</span></code></a> function converts big-endian samples to
little-endian and vice versa. (Contributed by Serhiy Storchaka in
<a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=19641">bpo-19641</a>.)</p>
<p>All <a class="reference internal" href="../library/audioop.html#module-audioop" title="audioop: Manipulate raw audio data. (kullanım dışı)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">audioop</span></code></a> functions now accept any <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like object</span></a>. Strings
are not accepted: they didn’t work before, now they raise an error right away.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=16685">bpo-16685</a>.)</p>
</section>
<section id="base64">
<h3>base64<a class="headerlink" href="#base64" title="Permalink to this heading">¶</a></h3>
<p>The encoding and decoding functions in <a class="reference internal" href="../library/base64.html#module-base64" title="base64: RFC 4648: Base16, Base32, Base64 Data Encodings; Base85 and Ascii85"><code class="xref py py-mod docutils literal notranslate"><span class="pre">base64</span></code></a> now accept any
<a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like object</span></a> in cases where it previously required a
<a class="reference internal" href="../library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> or <a class="reference internal" href="../library/stdtypes.html#bytearray" title="bytearray"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytearray</span></code></a> instance. (Contributed by Nick Coghlan in
<a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=17839">bpo-17839</a>.)</p>
<p>New functions <a class="reference internal" href="../library/base64.html#base64.a85encode" title="base64.a85encode"><code class="xref py py-func docutils literal notranslate"><span class="pre">a85encode()</span></code></a>, <a class="reference internal" href="../library/base64.html#base64.a85decode" title="base64.a85decode"><code class="xref py py-func docutils literal notranslate"><span class="pre">a85decode()</span></code></a>,
<a class="reference internal" href="../library/base64.html#base64.b85encode" title="base64.b85encode"><code class="xref py py-func docutils literal notranslate"><span class="pre">b85encode()</span></code></a>, and <a class="reference internal" href="../library/base64.html#base64.b85decode" title="base64.b85decode"><code class="xref py py-func docutils literal notranslate"><span class="pre">b85decode()</span></code></a> provide the ability to
encode and decode binary data from and to <code class="docutils literal notranslate"><span class="pre">Ascii85</span></code> and the git/mercurial
<code class="docutils literal notranslate"><span class="pre">Base85</span></code> formats, respectively. The <code class="docutils literal notranslate"><span class="pre">a85</span></code> functions have options that can
be used to make them compatible with the variants of the <code class="docutils literal notranslate"><span class="pre">Ascii85</span></code> encoding,
including the Adobe variant. (Contributed by Martin Morrison, the Mercurial
project, Serhiy Storchaka, and Antoine Pitrou in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=17618">bpo-17618</a>.)</p>
</section>
<section id="collections">
<h3>collections<a class="headerlink" href="#collections" title="Permalink to this heading">¶</a></h3>
<p>The <a class="reference internal" href="../library/collections.html#collections.ChainMap.new_child" title="collections.ChainMap.new_child"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ChainMap.new_child()</span></code></a> method now accepts an <em>m</em> argument specifying
the child map to add to the chain. This allows an existing mapping and/or a
custom mapping type to be used for the child. (Contributed by Vinay Sajip in
<a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=16613">bpo-16613</a>.)</p>
</section>
<section id="colorsys">
<h3>colorsys<a class="headerlink" href="#colorsys" title="Permalink to this heading">¶</a></h3>
<p>The number of digits in the coefficients for the RGB — YIQ conversions have
been expanded so that they match the FCC NTSC versions. The change in
results should be less than 1% and may better match results found elsewhere.
(Contributed by Brian Landers and Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=14323">bpo-14323</a>.)</p>
</section>
<section id="contextlib">
<h3>contextlib<a class="headerlink" href="#contextlib" title="Permalink to this heading">¶</a></h3>
<p>The new <a class="reference internal" href="../library/contextlib.html#contextlib.suppress" title="contextlib.suppress"><code class="xref py py-class docutils literal notranslate"><span class="pre">contextlib.suppress</span></code></a> context manager helps to clarify the
intent of code that deliberately suppresses exceptions from a single
statement. (Contributed by Raymond Hettinger in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=15806">bpo-15806</a> and
Zero Piraeus in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=19266">bpo-19266</a>.)</p>
<p>The new <a class="reference internal" href="../library/contextlib.html#contextlib.redirect_stdout" title="contextlib.redirect_stdout"><code class="xref py py-func docutils literal notranslate"><span class="pre">contextlib.redirect_stdout()</span></code></a> context manager makes it easier
for utility scripts to handle inflexible APIs that write their output to
<a class="reference internal" href="../library/sys.html#sys.stdout" title="sys.stdout"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stdout</span></code></a> and don’t provide any options to redirect it. Using the
context manager, the <a class="reference internal" href="../library/sys.html#sys.stdout" title="sys.stdout"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stdout</span></code></a> output can be redirected to any
other stream or, in conjunction with <a class="reference internal" href="../library/io.html#io.StringIO" title="io.StringIO"><code class="xref py py-class docutils literal notranslate"><span class="pre">io.StringIO</span></code></a>, to a string.
The latter can be especially useful, for example, to capture output
from a function that was written to implement a command line interface.
It is recommended only for utility scripts because it affects the
global state of <a class="reference internal" href="../library/sys.html#sys.stdout" title="sys.stdout"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stdout</span></code></a>. (Contributed by Raymond Hettinger
in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=15805">bpo-15805</a>.)</p>
<p>The <a class="reference internal" href="../library/contextlib.html#module-contextlib" title="contextlib: Utilities for with-statement contexts."><code class="xref py py-mod docutils literal notranslate"><span class="pre">contextlib</span></code></a> documentation has also been updated to include a
<a class="reference internal" href="../library/contextlib.html#single-use-reusable-and-reentrant-cms"><span class="std std-ref">discussion</span></a> of the
differences between single use, reusable and reentrant context managers.</p>
</section>
<section id="dbm">
<h3>dbm<a class="headerlink" href="#dbm" title="Permalink to this heading">¶</a></h3>
<p><a class="reference internal" href="../library/dbm.html#dbm.open" title="dbm.open"><code class="xref py py-func docutils literal notranslate"><span class="pre">dbm.open()</span></code></a> objects now support the context management protocol. When
used in a <a class="reference internal" href="../reference/compound_stmts.html#with"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">with</span></code></a> statement, the <code class="docutils literal notranslate"><span class="pre">close</span></code> method of the database
object will be called automatically at the end of the block. (Contributed by
Claudiu Popa and Nick Coghlan in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=19282">bpo-19282</a>.)</p>
</section>
<section id="dis">
<h3>dis<a class="headerlink" href="#dis" title="Permalink to this heading">¶</a></h3>
<p>Functions <a class="reference internal" href="../library/dis.html#dis.show_code" title="dis.show_code"><code class="xref py py-func docutils literal notranslate"><span class="pre">show_code()</span></code></a>, <a class="reference internal" href="../library/dis.html#dis.dis" title="dis.dis"><code class="xref py py-func docutils literal notranslate"><span class="pre">dis()</span></code></a>, <a class="reference internal" href="../library/dis.html#dis.distb" title="dis.distb"><code class="xref py py-func docutils literal notranslate"><span class="pre">distb()</span></code></a>, and
<a class="reference internal" href="../library/dis.html#dis.disassemble" title="dis.disassemble"><code class="xref py py-func docutils literal notranslate"><span class="pre">disassemble()</span></code></a> now accept a keyword-only <em>file</em> argument that
controls where they write their output.</p>
<p>The <a class="reference internal" href="../library/dis.html#module-dis" title="dis: Disassembler for Python bytecode."><code class="xref py py-mod docutils literal notranslate"><span class="pre">dis</span></code></a> module is now built around an <a class="reference internal" href="../library/dis.html#dis.Instruction" title="dis.Instruction"><code class="xref py py-class docutils literal notranslate"><span class="pre">Instruction</span></code></a> class
that provides object oriented access to the details of each individual bytecode
operation.</p>
<p>A new method, <a class="reference internal" href="../library/dis.html#dis.get_instructions" title="dis.get_instructions"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_instructions()</span></code></a>, provides an iterator that emits
the Instruction stream for a given piece of Python code. Thus it is now
possible to write a program that inspects and manipulates a bytecode
object in ways different from those provided by the <a class="reference internal" href="../library/dis.html#module-dis" title="dis: Disassembler for Python bytecode."><code class="xref py py-mod docutils literal notranslate"><span class="pre">dis</span></code></a> module
itself. For example:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">dis</span>
<span class="gp">>>> </span><span class="k">for</span> <span class="n">instr</span> <span class="ow">in</span> <span class="n">dis</span><span class="o">.</span><span class="n">get_instructions</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">):</span>
<span class="gp">... </span> <span class="nb">print</span><span class="p">(</span><span class="n">instr</span><span class="o">.</span><span class="n">opname</span><span class="p">)</span>
<span class="go">LOAD_FAST</span>
<span class="go">LOAD_CONST</span>
<span class="go">BINARY_ADD</span>
<span class="go">RETURN_VALUE</span>
</pre></div>
</div>
<p>The various display tools in the <a class="reference internal" href="../library/dis.html#module-dis" title="dis: Disassembler for Python bytecode."><code class="xref py py-mod docutils literal notranslate"><span class="pre">dis</span></code></a> module have been rewritten to use
these new components.</p>
<p>In addition, a new application-friendly class <a class="reference internal" href="../library/dis.html#dis.Bytecode" title="dis.Bytecode"><code class="xref py py-class docutils literal notranslate"><span class="pre">Bytecode</span></code></a> provides
an object-oriented API for inspecting bytecode in both in human-readable form
and for iterating over instructions. The <a class="reference internal" href="../library/dis.html#dis.Bytecode" title="dis.Bytecode"><code class="xref py py-class docutils literal notranslate"><span class="pre">Bytecode</span></code></a> constructor
takes the same arguments that <code class="xref py py-func docutils literal notranslate"><span class="pre">get_instruction()</span></code> does (plus an
optional <em>current_offset</em>), and the resulting object can be iterated to produce
<a class="reference internal" href="../library/dis.html#dis.Instruction" title="dis.Instruction"><code class="xref py py-class docutils literal notranslate"><span class="pre">Instruction</span></code></a> objects. But it also has a <a class="reference internal" href="../library/dis.html#dis.Bytecode.dis" title="dis.Bytecode.dis"><code class="xref py py-mod docutils literal notranslate"><span class="pre">dis</span></code></a>
method, equivalent to calling <a class="reference internal" href="../library/dis.html#dis.dis" title="dis.dis"><code class="xref py py-mod docutils literal notranslate"><span class="pre">dis</span></code></a> on the constructor argument, but
returned as a multi-line string:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">bytecode</span> <span class="o">=</span> <span class="n">dis</span><span class="o">.</span><span class="n">Bytecode</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">current_offset</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span>
<span class="gp">>>> </span><span class="k">for</span> <span class="n">instr</span> <span class="ow">in</span> <span class="n">bytecode</span><span class="p">:</span>
<span class="gp">... </span> <span class="nb">print</span><span class="p">(</span><span class="s1">'</span><span class="si">{}</span><span class="s1"> (</span><span class="si">{}</span><span class="s1">)'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">instr</span><span class="o">.</span><span class="n">opname</span><span class="p">,</span> <span class="n">instr</span><span class="o">.</span><span class="n">opcode</span><span class="p">))</span>
<span class="go">LOAD_FAST (124)</span>
<span class="go">LOAD_CONST (100)</span>
<span class="go">BINARY_ADD (23)</span>
<span class="go">RETURN_VALUE (83)</span>
<span class="gp">>>> </span><span class="n">bytecode</span><span class="o">.</span><span class="n">dis</span><span class="p">()</span><span class="o">.</span><span class="n">splitlines</span><span class="p">()</span>
<span class="go">[' 1 0 LOAD_FAST 0 (x)',</span>
<span class="go"> ' --> 3 LOAD_CONST 1 (1)',</span>
<span class="go"> ' 6 BINARY_ADD',</span>
<span class="go"> ' 7 RETURN_VALUE']</span>
</pre></div>
</div>
<p><a class="reference internal" href="../library/dis.html#dis.Bytecode" title="dis.Bytecode"><code class="xref py py-class docutils literal notranslate"><span class="pre">Bytecode</span></code></a> also has a class method,
<a class="reference internal" href="../library/dis.html#dis.Bytecode.from_traceback" title="dis.Bytecode.from_traceback"><code class="xref py py-meth docutils literal notranslate"><span class="pre">from_traceback()</span></code></a>, that provides the ability to manipulate a
traceback (that is, <code class="docutils literal notranslate"><span class="pre">print(Bytecode.from_traceback(tb).dis())</span></code> is equivalent
to <code class="docutils literal notranslate"><span class="pre">distb(tb)</span></code>).</p>
<p>(Contributed by Nick Coghlan, Ryan Kelly and Thomas Kluyver in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=11816">bpo-11816</a>
and Claudiu Popa in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=17916">bpo-17916</a>.)</p>
<p>New function <a class="reference internal" href="../library/dis.html#dis.stack_effect" title="dis.stack_effect"><code class="xref py py-func docutils literal notranslate"><span class="pre">stack_effect()</span></code></a> computes the effect on the Python stack
of a given opcode and argument, information that is not otherwise available.
(Contributed by Larry Hastings in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=19722">bpo-19722</a>.)</p>
</section>
<section id="doctest">
<h3>doctest<a class="headerlink" href="#doctest" title="Permalink to this heading">¶</a></h3>
<p>A new <a class="reference internal" href="../library/doctest.html#doctest-options"><span class="std std-ref">option flag</span></a>, <a class="reference internal" href="../library/doctest.html#doctest.FAIL_FAST" title="doctest.FAIL_FAST"><code class="xref py py-const docutils literal notranslate"><span class="pre">FAIL_FAST</span></code></a>, halts
test running as soon as the first failure is detected. (Contributed by R.
David Murray and Daniel Urban in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=16522">bpo-16522</a>.)</p>
<p>The <a class="reference internal" href="../library/doctest.html#module-doctest" title="doctest: Test pieces of code within docstrings."><code class="xref py py-mod docutils literal notranslate"><span class="pre">doctest</span></code></a> command line interface now uses <a class="reference internal" href="../library/argparse.html#module-argparse" title="argparse: Command-line option and argument parsing library."><code class="xref py py-mod docutils literal notranslate"><span class="pre">argparse</span></code></a>, and has two
new options, <code class="docutils literal notranslate"><span class="pre">-o</span></code> and <code class="docutils literal notranslate"><span class="pre">-f</span></code>. <code class="docutils literal notranslate"><span class="pre">-o</span></code> allows <a class="reference internal" href="../library/doctest.html#doctest-options"><span class="std std-ref">doctest options</span></a> to be specified on the command line, and <code class="docutils literal notranslate"><span class="pre">-f</span></code> is a
shorthand for <code class="docutils literal notranslate"><span class="pre">-o</span> <span class="pre">FAIL_FAST</span></code> (to parallel the similar option supported by the
<a class="reference internal" href="../library/unittest.html#module-unittest" title="unittest: Unit testing framework for Python."><code class="xref py py-mod docutils literal notranslate"><span class="pre">unittest</span></code></a> CLI). (Contributed by R. David Murray in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=11390">bpo-11390</a>.)</p>
<p><a class="reference internal" href="../library/doctest.html#module-doctest" title="doctest: Test pieces of code within docstrings."><code class="xref py py-mod docutils literal notranslate"><span class="pre">doctest</span></code></a> will now find doctests in extension module <code class="docutils literal notranslate"><span class="pre">__doc__</span></code> strings.
(Contributed by Zachary Ware in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=3158">bpo-3158</a>.)</p>
</section>
<section id="email">
<h3>email<a class="headerlink" href="#email" title="Permalink to this heading">¶</a></h3>
<p><a class="reference internal" href="../library/email.compat32-message.html#email.message.Message.as_string" title="email.message.Message.as_string"><code class="xref py py-meth docutils literal notranslate"><span class="pre">as_string()</span></code></a> now accepts a <em>policy</em> argument to
override the default policy of the message when generating a string
representation of it. This means that <code class="docutils literal notranslate"><span class="pre">as_string</span></code> can now be used in more
circumstances, instead of having to create and use a <a class="reference internal" href="../library/email.generator.html#module-email.generator" title="email.generator: Generate flat text email messages from a message structure."><code class="xref py py-mod docutils literal notranslate"><span class="pre">generator</span></code></a> in
order to pass formatting parameters to its <code class="docutils literal notranslate"><span class="pre">flatten</span></code> method. (Contributed by
R. David Murray in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=18600">bpo-18600</a>.)</p>
<p>New method <a class="reference internal" href="../library/email.compat32-message.html#email.message.Message.as_bytes" title="email.message.Message.as_bytes"><code class="xref py py-meth docutils literal notranslate"><span class="pre">as_bytes()</span></code></a> added to produce a bytes
representation of the message in a fashion similar to how <code class="docutils literal notranslate"><span class="pre">as_string</span></code>
produces a string representation. It does not accept the <em>maxheaderlen</em>
argument, but does accept the <em>unixfrom</em> and <em>policy</em> arguments. The
<a class="reference internal" href="../library/email.compat32-message.html#email.message.Message" title="email.message.Message"><code class="xref py py-class docutils literal notranslate"><span class="pre">Message</span></code></a> <a class="reference internal" href="../library/email.compat32-message.html#email.message.Message.__bytes__" title="email.message.Message.__bytes__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__bytes__()</span></code></a> method
calls it, meaning that <code class="docutils literal notranslate"><span class="pre">bytes(mymsg)</span></code> will now produce the intuitive
result: a bytes object containing the fully formatted message. (Contributed
by R. David Murray in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=18600">bpo-18600</a>.)</p>
<p>The <a class="reference internal" href="../library/email.compat32-message.html#email.message.Message.set_param" title="email.message.Message.set_param"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Message.set_param()</span></code></a> message now accepts a <em>replace</em> keyword argument.
When specified, the associated header will be updated without changing
its location in the list of headers. For backward compatibility, the default
is <code class="docutils literal notranslate"><span class="pre">False</span></code>. (Contributed by R. David Murray in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=18891">bpo-18891</a>.)</p>
<p id="whatsnew-email-contentmanager">A pair of new subclasses of <a class="reference internal" href="../library/email.compat32-message.html#email.message.Message" title="email.message.Message"><code class="xref py py-class docutils literal notranslate"><span class="pre">Message</span></code></a> have been added
(<a class="reference internal" href="../library/email.message.html#email.message.EmailMessage" title="email.message.EmailMessage"><code class="xref py py-class docutils literal notranslate"><span class="pre">EmailMessage</span></code></a> and <a class="reference internal" href="../library/email.message.html#email.message.MIMEPart" title="email.message.MIMEPart"><code class="xref py py-class docutils literal notranslate"><span class="pre">MIMEPart</span></code></a>), along with a new sub-module,
<a class="reference internal" href="../library/email.contentmanager.html#module-email.contentmanager" title="email.contentmanager: Storing and Retrieving Content from MIME Parts"><code class="xref py py-mod docutils literal notranslate"><span class="pre">contentmanager</span></code></a> and a new <a class="reference internal" href="../library/email.policy.html#module-email.policy" title="email.policy: Controlling the parsing and generating of messages"><code class="xref py py-mod docutils literal notranslate"><span class="pre">policy</span></code></a> attribute
<a class="reference internal" href="../library/email.policy.html#email.policy.EmailPolicy.content_manager" title="email.policy.EmailPolicy.content_manager"><code class="xref py py-attr docutils literal notranslate"><span class="pre">content_manager</span></code></a>. All documentation is
currently in the new module, which is being added as part of email’s new
<a class="reference internal" href="../glossary.html#term-provisional-API"><span class="xref std std-term">provisional API</span></a>. These classes provide a number of new methods that
make extracting content from and inserting content into email messages much
easier. For details, see the <a class="reference internal" href="../library/email.contentmanager.html#module-email.contentmanager" title="email.contentmanager: Storing and Retrieving Content from MIME Parts"><code class="xref py py-mod docutils literal notranslate"><span class="pre">contentmanager</span></code></a> documentation and
the <a class="reference internal" href="../library/email.examples.html#email-examples"><span class="std std-ref">email: Examples</span></a>. These API additions complete the
bulk of the work that was planned as part of the email6 project. The currently
provisional API is scheduled to become final in Python 3.5 (possibly with a few
minor additions in the area of error handling). (Contributed by R. David
Murray in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=18891">bpo-18891</a>.)</p>
</section>
<section id="filecmp">
<h3>filecmp<a class="headerlink" href="#filecmp" title="Permalink to this heading">¶</a></h3>
<p>A new <a class="reference internal" href="../library/filecmp.html#filecmp.clear_cache" title="filecmp.clear_cache"><code class="xref py py-func docutils literal notranslate"><span class="pre">clear_cache()</span></code></a> function provides the ability to clear the
<a class="reference internal" href="../library/filecmp.html#module-filecmp" title="filecmp: Compare files efficiently."><code class="xref py py-mod docutils literal notranslate"><span class="pre">filecmp</span></code></a> comparison cache, which uses <a class="reference internal" href="../library/os.html#os.stat" title="os.stat"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.stat()</span></code></a> information to
determine if the file has changed since the last compare. This can be used,
for example, if the file might have been changed and re-checked in less time
than the resolution of a particular filesystem’s file modification time field.
(Contributed by Mark Levitt in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=18149">bpo-18149</a>.)</p>
<p>New module attribute <a class="reference internal" href="../library/filecmp.html#filecmp.DEFAULT_IGNORES" title="filecmp.DEFAULT_IGNORES"><code class="xref py py-const docutils literal notranslate"><span class="pre">DEFAULT_IGNORES</span></code></a> provides the list of
directories that are used as the default value for the <em>ignore</em> parameter of
the <a class="reference internal" href="../library/filecmp.html#filecmp.dircmp" title="filecmp.dircmp"><code class="xref py py-func docutils literal notranslate"><span class="pre">dircmp()</span></code></a> function. (Contributed by Eli Bendersky in
<a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=15442">bpo-15442</a>.)</p>
</section>
<section id="functools">
<h3>functools<a class="headerlink" href="#functools" title="Permalink to this heading">¶</a></h3>
<p>The new <a class="reference internal" href="../library/functools.html#functools.partialmethod" title="functools.partialmethod"><code class="xref py py-func docutils literal notranslate"><span class="pre">partialmethod()</span></code></a> descriptor brings partial argument
application to descriptors, just as <a class="reference internal" href="../library/functools.html#functools.partial" title="functools.partial"><code class="xref py py-func docutils literal notranslate"><span class="pre">partial()</span></code></a> provides
for normal callables. The new descriptor also makes it easier to get
arbitrary callables (including <a class="reference internal" href="../library/functools.html#functools.partial" title="functools.partial"><code class="xref py py-func docutils literal notranslate"><span class="pre">partial()</span></code></a> instances)
to behave like normal instance methods when included in a class definition.
(Contributed by Alon Horev and Nick Coghlan in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=4331">bpo-4331</a>.)</p>
<p id="whatsnew-singledispatch">The new <a class="reference internal" href="../library/functools.html#functools.singledispatch" title="functools.singledispatch"><code class="xref py py-func docutils literal notranslate"><span class="pre">singledispatch()</span></code></a> decorator brings support for
single-dispatch generic functions to the Python standard library. Where
object oriented programming focuses on grouping multiple operations on a
common set of data into a class, a generic function focuses on grouping
multiple implementations of an operation that allows it to work with
<em>different</em> kinds of data.</p>
<div class="admonition seealso">
<p class="admonition-title">Ayrıca bakınız</p>
<dl class="simple">
<dt><span class="target" id="index-36"></span><a class="pep reference external" href="https://peps.python.org/pep-0443/"><strong>PEP 443</strong></a> – Single-dispatch generic functions</dt><dd><p>PEP written and implemented by Łukasz Langa.</p>
</dd>
</dl>
</div>
<p><a class="reference internal" href="../library/functools.html#functools.total_ordering" title="functools.total_ordering"><code class="xref py py-func docutils literal notranslate"><span class="pre">total_ordering()</span></code></a> now supports a return value of
<a class="reference internal" href="../library/constants.html#NotImplemented" title="NotImplemented"><code class="xref py py-const docutils literal notranslate"><span class="pre">NotImplemented</span></code></a> from the underlying comparison function. (Contributed
by Katie Miller in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=10042">bpo-10042</a>.)</p>
<p>A pure-python version of the <a class="reference internal" href="../library/functools.html#functools.partial" title="functools.partial"><code class="xref py py-func docutils literal notranslate"><span class="pre">partial()</span></code></a> function is now in the
stdlib; in CPython it is overridden by the C accelerated version, but it is
available for other implementations to use. (Contributed by Brian Thorne in
<a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=12428">bpo-12428</a>.)</p>
</section>
<section id="gc">
<h3>gc<a class="headerlink" href="#gc" title="Permalink to this heading">¶</a></h3>