
8.6 Other Objects .............................................173
8.6.1 File Objects .........................................173
8.6.2 Module Objects .......................................174
8.6.3 Iterator Objects .......................................182
8.6.4 Descriptor Objects .....................................183
8.6.5 Slice Objects ........................................183
8.6.6 MemoryView objects ....................................185
8.6.7 Weak Reference Objects ..................................185
8.6.8 Capsules ...........................................187
8.6.9 Frame Objects ........................................188
8.6.10 Generator Objects ......................................191
8.6.11 Coroutine Objects ......................................191
8.6.12 Context Variables Objects ..................................192
8.6.13 DateTime Objects ......................................193
8.6.14 Objects for Type Hinting ..................................197
9 Initialization, Finalization, and Threads 199
9.1 Before Python Initialization ......................................199
9.2 Global conguration variables ....................................200
9.3 Initializing and nalizing the interpreter ...............................203
9.4 Process-wide parameters .......................................206
9.5 Thread State and the Global Interpreter Lock ............................209
9.5.1 Releasing the GIL from extension code ...........................209
9.5.2 Non-Python created threads .................................210
9.5.3 Cautions about fork() ....................................210
9.5.4 High-level API .......................................211
9.5.5 Low-level API ........................................213
9.6 Sub-interpreter support ........................................216
9.6.1 A Per-Interpreter GIL ....................................218
9.6.2 Bugs and caveats ......................................219
9.7 Asynchronous Notications ......................................219
9.8 Proling and Tracing .........................................220
9.9 Reference tracing ...........................................221
9.10 Advanced Debugger Support .....................................222
9.11 Thread Local Storage Support ....................................222
9.11.1 Thread Specic Storage (TSS) API .............................223
9.11.2 Thread Local Storage (TLS) API ..............................224
9.12 Synchronization Primitives ......................................225
9.12.1 Python Critical Section API .................................225
10 Python Initialization Conguration 227
10.1 Example ...............................................227
10.2 PyWideStringList ...........................................228
10.3 PyStatus ...............................................228
10.4 PyPreCong .............................................230
10.5 Preinitialize Python with PyPreCong ................................231
10.6 PyCong ...............................................232
10.7 Initialization with PyCong ......................................243
10.8 Isolated Conguration ........................................245
10.9 Python Conguration .........................................245
10.10 Python Path Conguration ......................................245
10.11 Py_GetArgcArgv() ..........................................246
10.12 Multi-Phase Initialization Private Provisional API ..........................247
11 Memory Management 249
11.1 Overview ...............................................249
11.2 Allocator Domains ..........................................250
11.3 Raw Memory Interface ........................................250
11.4 Memory Interface ...........................................251
iii