'Is it possible to modify the function Py_DECREF in cpython?If possible, how?
I want to use my own memory management policy when calling function Py_DECREF, so I wonder wheather it is possible to modify the functiong Py_DECREF. If possible, how?
Solution 1:[1]
Shortly, yes you can change it, but only for your local instance of Python.
More extensive:
In terms of Python code, no, you can't change Py_DECREF function because it is not a python object. In terms of C/C++ code of an extension you may be writing, you also can't change this function because it is a part of CPython project and it's very core which is also used by Python/C API, so you should not change it, because it will change not only behavior of your specific extension, but also the behavior of the entire language. The only way to change this function is to change it's C source code here:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Obsidian |
