Skip to content

Commit 1e8d6c4

Browse files
committed
Exclude pthread_stubs.h
1 parent fe97e22 commit 1e8d6c4

2 files changed

Lines changed: 49 additions & 35 deletions

File tree

‎doc/pythoncapi.py‎

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,16 @@ def git_switch_branch(branch):
8686
def list_files(path):
8787
if not os.path.exists(path):
8888
return []
89-
return glob.glob(os.path.join(path, '*.h'))
89+
files = glob.glob(os.path.join(path, '*.h'))
90+
# Don't parse pthread_stubs.h: special header file used by WASM
91+
for index, name in enumerate(files):
92+
if os.path.basename(name) == 'pthread_stubs.h':
93+
del files[index]
94+
break
95+
return files
9096

9197

9298
def _get_types(filename, names):
93-
if 'pthread_stubs.h' in filename:
94-
# skip special header file used by WASM
95-
return
9699
if os.path.basename(filename) == 'pystats.h':
97100
# skip Include/pystats.h which is code only used if Python is built
98101
# with --enable-pystats (if the Py_STATS macro is defined)
@@ -105,16 +108,19 @@ def _get_types(filename, names):
105108
struct_name = match.group(1)
106109
match2 = RE_STRUCT_END.search(content, match.end())
107110
if not match2:
108-
raise Exception(f"cannot find end of: {filename}: {match.group()}")
111+
raise Exception(f"{filename}: cannot find end of: {match.group()}")
109112
name = match2.group(1)
110113
if not name:
111114
name = struct_name
112115
if not name:
113-
raise Exception(f"structure has no name: {filename}: {match.group()})")
116+
raise Exception(f"{filename}: structure has no name: {match.group()})")
114117
if name in TYPEDEFS:
115118
name = TYPEDEFS[name]
116119
names.add(name)
117120

121+
if 'pthread_mutex_t' in names:
122+
raise Exception('pthread_stubs.h was parsed')
123+
118124

119125
def get_types_path(directory):
120126
names = set()
@@ -170,6 +176,10 @@ def get_macros_static_inline_funcs():
170176
return (macros, funcs)
171177

172178

179+
def is_function_public(name):
180+
return name.startswith(('Py', 'PY'))
181+
182+
173183
def get_functions():
174184
regex = re.compile(
175185
# 'PyAPI_FUNC(int) '
@@ -188,13 +198,17 @@ def get(path):
188198
cpython = get(PATH_CPYTHON_API)
189199
internal = get(PATH_INTERNAL_API)
190200

201+
for names in (limited, cpython, internal):
202+
if 'pthread_create' in names:
203+
raise Exception('pthread_stubs.h was parsed')
204+
191205
public = set()
192206
private = set()
193207
for name in limited | cpython:
194-
if name.startswith('_Py'):
195-
private.add(name)
196-
else:
208+
if is_function_public(name):
197209
public.add(name)
210+
else:
211+
private.add(name)
198212

199213
return (public, private, internal)
200214

@@ -255,10 +269,10 @@ def get(path):
255269
public = set()
256270
private = set()
257271
for name in limited | cpython:
258-
if name.startswith('_Py'):
259-
private.add(name)
260-
else:
272+
if is_function_public(name):
261273
public.add(name)
274+
else:
275+
private.add(name)
262276

263277
return (public, private, internal)
264278

‎doc/stats.rst‎

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ Python Limited API CPython API Internal API Total
1616
3.8.0 13,147 (70%) 3,418 (18%) 2,207 (12%) 18,772
1717
3.9.0 12,243 (62%) 4,359 (22%) 3,084 (16%) 19,686
1818
3.10.0 10,408 (51%) 4,584 (22%) 5,519 (27%) 20,511
19-
3.11.0 9,232 (37%) 5,495 (22%) 10,047 (41%) 24,774
20-
3.12 (dev) 9,598 (29%) 5,903 (18%) 17,631 (53%) 33,132
21-
main (3.13) 9,344 (28%) 5,207 (16%) 18,556 (56%) 33,107
19+
3.11.0 9,232 (37%) 5,407 (22%) 10,047 (41%) 24,686
20+
3.12 (dev) 9,598 (29%) 5,815 (18%) 17,631 (53%) 33,044
21+
main (3.13) 9,344 (28%) 5,050 (15%) 18,624 (56%) 33,018
2222
=========== ============= =========== ============ ======
2323

2424
File Numbers
@@ -35,29 +35,29 @@ Python Limited API CPython API Internal API Total
3535
3.8.0 97 (-2) 15 (+15) 21 (+10) 133 (+23)
3636
3.9.0 98 (+1) 24 (+9) 33 (+12) 155 (+22)
3737
3.10.0 81 (-17) 32 (+8) 48 (+15) 161 (+6)
38-
3.11.0 72 (-9) 48 (+16) 68 (+20) 188 (+27)
39-
3.12 (dev) 72 (same) 49 (+1) 91 (+23) 212 (+24)
40-
main (3.13) 72 (same) 51 (+2) 95 (+4) 218 (+6)
38+
3.11.0 72 (-9) 47 (+15) 68 (+20) 187 (+26)
39+
3.12 (dev) 72 (same) 48 (+1) 91 (+23) 211 (+24)
40+
main (3.13) 72 (same) 50 (+2) 95 (+4) 217 (+6)
4141
=========== =========== =========== ============ =========
4242

4343
Functions
4444
=========
4545

4646
Functions exported with PyAPI_FUNC():
4747

48-
=========== ========= ========== ========= ============
49-
Python Public Private Internal Total
50-
=========== ========= ========== ========= ============
51-
2.7.0 748 150 0 898
52-
3.6.0 847 (+99) 380 (+230) 0 (same) 1,227 (+329)
53-
3.7.0 872 (+25) 448 (+68) 12 (+12) 1,332 (+105)
54-
3.8.0 910 (+38) 429 (-19) 78 (+66) 1,417 (+85)
55-
3.9.0 919 (+9) 412 (-17) 109 (+31) 1,440 (+23)
56-
3.10.0 885 (-34) 412 (same) 115 (+6) 1,412 (-28)
57-
3.11.0 914 (+29) 360 (-52) 176 (+61) 1,450 (+38)
58-
3.12 (dev) 951 (+37) 385 (+25) 177 (+1) 1,513 (+63)
59-
main (3.13) 935 (-16) 268 (-117) 236 (+59) 1,439 (-74)
60-
=========== ========= ========== ========= ============
48+
=========== ========== ========== ========= ============
49+
Python Public Private Internal Total
50+
=========== ========== ========== ========= ============
51+
2.7.0 738 160 0 898
52+
3.6.0 844 (+106) 383 (+223) 0 (same) 1,227 (+329)
53+
3.7.0 869 (+25) 451 (+68) 12 (+12) 1,332 (+105)
54+
3.8.0 909 (+40) 430 (-21) 78 (+66) 1,417 (+85)
55+
3.9.0 919 (+10) 412 (-18) 109 (+31) 1,440 (+23)
56+
3.10.0 885 (-34) 412 (same) 115 (+6) 1,412 (-28)
57+
3.11.0 891 (+6) 360 (-52) 176 (+61) 1,427 (+15)
58+
3.12 (dev) 928 (+37) 385 (+25) 177 (+1) 1,490 (+63)
59+
main (3.13) 912 (-16) 259 (-126) 237 (+60) 1,408 (-82)
60+
=========== ========== ========== ========= ============
6161

6262
Since Python 3.9, Python is now built with ``-fvisibility=hidden`` to avoid
6363
exporting symbols which are not **explicitly** exported.
@@ -74,15 +74,15 @@ Symbols exported with PyAPI_DATA():
7474
=========== ========== ======== ========= ==========
7575
Python Public Private Internal Total
7676
=========== ========== ======== ========= ==========
77-
2.7.0 130 29 0 159
78-
3.6.0 167 (+37) 42 (+13) 0 (same) 209 (+50)
77+
2.7.0 129 30 0 159
78+
3.6.0 167 (+38) 42 (+12) 0 (same) 209 (+50)
7979
3.7.0 170 (+3) 35 (-7) 9 (+9) 214 (+5)
8080
3.8.0 174 (+4) 37 (+2) 12 (+3) 223 (+9)
8181
3.9.0 173 (-1) 35 (-2) 14 (+2) 222 (-1)
8282
3.10.0 173 (same) 33 (-2) 13 (-1) 219 (-3)
8383
3.11.0 177 (+4) 32 (-1) 10 (-3) 219 (same)
84-
3.12 (dev) 178 (+1) 29 (-3) 12 (+2) 219 (same)
85-
main (3.13) 178 (same) 30 (+1) 12 (same) 220 (+1)
84+
3.12 (dev) 176 (-1) 31 (-1) 12 (+2) 219 (same)
85+
main (3.13) 176 (same) 32 (+1) 12 (same) 220 (+1)
8686
=========== ========== ======== ========= ==========
8787

8888
Functions defined as macros and static inline functions

0 commit comments

Comments
 (0)