Skip to content

Commit 116fa62

Browse files
authored
gh-97670: Remove sys.getdxp() and analyze_dxp.py script (#97671)
Remove the sys.getdxp() function and the Tools/scripts/analyze_dxp.py script. DXP stands for "dynamic execution pairs". They were related to DYNAMIC_EXECUTION_PROFILE and DXPAIRS macros which have been removed in Python 3.11. Python can now be built with "./configure --enable-pystats" to gather statistics on Python opcodes.
1 parent 6e53308 commit 116fa62

File tree

6 files changed

+7
-201
lines changed

6 files changed

+7
-201
lines changed

Lib/test/test_tools/test_sundry.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class TestSundryScripts(unittest.TestCase):
2525
# scripts that use windows-only modules
2626
windows_only = ['win_add2path']
2727
# denylisted for other reasons
28-
other = ['analyze_dxp', '2to3']
28+
other = ['2to3']
2929

3030
skiplist = denylist + allowlist + windows_only + other
3131

@@ -50,13 +50,6 @@ def test_sundry_windows(self):
5050
for name in self.windows_only:
5151
import_tool(name)
5252

53-
def test_analyze_dxp_import(self):
54-
if hasattr(sys, 'getdxp'):
55-
import_tool('analyze_dxp')
56-
else:
57-
with self.assertRaises(RuntimeError):
58-
import_tool('analyze_dxp')
59-
6053

6154
if __name__ == '__main__':
6255
unittest.main()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Remove the :func:`sys.getdxp` function and the ``Tools/scripts/analyze_dxp.py``
2+
script. DXP stands for "dynamic execution pairs". They were related to
3+
``DYNAMIC_EXECUTION_PROFILE`` and ``DXPAIRS`` macros which have been removed in
4+
Python 3.11. Python can now be built with :option:`./configure --enable-pystats
5+
<--enable-pystats>` to gather statistics on Python opcodes. Patch by Victor
6+
Stinner.

Python/ceval.c

-55
Original file line numberDiff line numberDiff line change
@@ -7207,61 +7207,6 @@ format_awaitable_error(PyThreadState *tstate, PyTypeObject *type, int oparg)
72077207
}
72087208
}
72097209

7210-
#ifdef Py_STATS
7211-
7212-
static PyObject *
7213-
getarray(uint64_t a[256])
7214-
{
7215-
int i;
7216-
PyObject *l = PyList_New(256);
7217-
if (l == NULL) return NULL;
7218-
for (i = 0; i < 256; i++) {
7219-
PyObject *x = PyLong_FromUnsignedLongLong(a[i]);
7220-
if (x == NULL) {
7221-
Py_DECREF(l);
7222-
return NULL;
7223-
}
7224-
PyList_SET_ITEM(l, i, x);
7225-
}
7226-
for (i = 0; i < 256; i++)
7227-
a[i] = 0;
7228-
return l;
7229-
}
7230-
7231-
PyObject *
7232-
_Py_GetDXProfile(PyObject *self, PyObject *args)
7233-
{
7234-
int i;
7235-
PyObject *l = PyList_New(257);
7236-
if (l == NULL) return NULL;
7237-
for (i = 0; i < 256; i++) {
7238-
PyObject *x = getarray(_py_stats_struct.opcode_stats[i].pair_count);
7239-
if (x == NULL) {
7240-
Py_DECREF(l);
7241-
return NULL;
7242-
}
7243-
PyList_SET_ITEM(l, i, x);
7244-
}
7245-
PyObject *counts = PyList_New(256);
7246-
if (counts == NULL) {
7247-
Py_DECREF(l);
7248-
return NULL;
7249-
}
7250-
for (i = 0; i < 256; i++) {
7251-
PyObject *x = PyLong_FromUnsignedLongLong(
7252-
_py_stats_struct.opcode_stats[i].execution_count);
7253-
if (x == NULL) {
7254-
Py_DECREF(counts);
7255-
Py_DECREF(l);
7256-
return NULL;
7257-
}
7258-
PyList_SET_ITEM(counts, i, x);
7259-
}
7260-
PyList_SET_ITEM(l, 256, counts);
7261-
return l;
7262-
}
7263-
7264-
#endif
72657210

72667211
Py_ssize_t
72677212
_PyEval_RequestCodeExtraIndex(freefunc free)

Python/sysmodule.c

-8
Original file line numberDiff line numberDiff line change
@@ -2014,11 +2014,6 @@ sys__debugmallocstats_impl(PyObject *module)
20142014
extern PyObject *_Py_GetObjects(PyObject *, PyObject *);
20152015
#endif
20162016

2017-
#ifdef Py_STATS
2018-
/* Defined in ceval.c because it uses static globals in that file */
2019-
extern PyObject *_Py_GetDXProfile(PyObject *, PyObject *);
2020-
#endif
2021-
20222017
#ifdef __cplusplus
20232018
}
20242019
#endif
@@ -2217,9 +2212,6 @@ static PyMethodDef sys_methods[] = {
22172212
SYS_GETDEFAULTENCODING_METHODDEF
22182213
SYS_GETDLOPENFLAGS_METHODDEF
22192214
SYS_GETALLOCATEDBLOCKS_METHODDEF
2220-
#ifdef Py_STATS
2221-
{"getdxp", _Py_GetDXProfile, METH_VARARGS},
2222-
#endif
22232215
SYS_GETFILESYSTEMENCODING_METHODDEF
22242216
SYS_GETFILESYSTEMENCODEERRORS_METHODDEF
22252217
SYS__GETQUICKENEDCOUNT_METHODDEF

Tools/scripts/README

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ useful while building, extending or managing Python.
33

44
2to3 Main script for running the 2to3 conversion tool
55
abitype.py Converts a C file to use the PEP 384 type definition API
6-
analyze_dxp.py Analyzes the result of sys.getdxp()
76
combinerefs.py A helper for analyzing PYTHONDUMPREFS output
87
diff.py Print file diffs in context, unified, or ndiff formats
98
eptags.py Create Emacs TAGS file for Python modules

Tools/scripts/analyze_dxp.py

-129
This file was deleted.

0 commit comments

Comments
 (0)