The scripting_context pointer itself does not change and nor does it need to. Put it directly into the script as a variable at the start so it does not have to be passed on each call into the script.
Showing the changes to tools/perf/scripts/python (1 of 2 files). Show all
Unified · Split
| @@ -91,6 +91,12 @@ PyMODINIT_FUNC PyInit_perf_trace_context(void) · 90 unmodified lines | ||
| 91 | 91 | NULL, /* m_clear */ |
| 92 | 92 | NULL, /* m_free */ |
| 93 | 93 | }; |
| 94 | − return PyModule_Create(&moduledef); | |
| 94 | + PyObject *mod; | |
| 95 | + | |
| 96 | + mod = PyModule_Create(&moduledef); | |
| 97 | + /* Add perf_script_context to the module so it can be imported */ | |
| 98 | + PyObject_SetAttrString(mod, "perf_script_context", Py_None); | |
| 99 | + | |
| 100 | + return mod; | |
| 95 | 101 | } |
| 96 | 102 | #endif |