FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpython/Tools/c-analyzer/README at 3.9 · python-emscripten/cpython · GitHub
python-emscripten
cpython
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpython
/
Tools
/
c-analyzer
/
README
Copy path
More file actions
More file actions
Latest commit
History
History
History
41 lines (33 loc) · 1.8 KB
Breadcrumbs
cpython
/
Tools
/
c-analyzer
/
README
Copy path
File metadata and controls
41 lines (33 loc) · 1.8 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#######################################
# C Globals and CPython Runtime State.
CPython's C code makes extensive use of global variables. Each global
falls into one of several categories:
* (effectively) constants (incl. static types)
* globals used exclusively in main or in the REPL
* freelists, caches, and counters
* process-global state
* module state
* Python runtime state
The ignored-globals.txt file is organized similarly. Of the different
categories, the last two are problematic and generally should not exist
in the codebase.
Globals that hold module state (i.e. in Modules/*.c) cause problems
when multiple interpreters are in use. For more info, see PEP 3121,
which addresses the situation for extension modules in general.
Globals in the last category should be avoided as well. The problem
isn't with the Python runtime having state. Rather, the problem is with
that state being spread throughout the codebase in dozens of individual
globals. Unlike the other globals, the runtime state represents a set
of values that are constantly shifting in a complex way. When they are
spread out it's harder to get a clear picture of what the runtime
involves. Furthermore, when they are spread out it complicates efforts
that change the runtime.
Consequently, the globals for Python's runtime state have been
consolidated under a single top-level _PyRuntime global. No new globals
should be added for runtime state. Instead, they should be added to
_PyRuntimeState or one of its sub-structs. The check-c-globals script
should be run to ensure that no new globals have been added:
python3 Tools/c-analyzer/check-c-globals.py
If it reports any globals then they should be resolved. If the globals
are runtime state then they should be folded into _PyRuntimeState.
Otherwise they should be added to ignored-globals.txt.
Back
|
FazBrowse Home
|
New Git URL