A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://pythoncapi.readthedocs.io/backward_compatibility.html below:

Backward compatibility — pythoncapi 0.1 documentation

Backward compatibility

To reduce the risk of failure, changing the C API should be as much as possible compatible with the old C API (Python 3.7 C API). One solution for that is to provide a backward compatible header file and/or library.

Backward compatibility with Python 3.7 and older

For example, if PyDict_GetItem() is removed because it returns a borrowed reference, a new function PyDict_GetItemRef() which increases the reference counter can be added in the new API. But to make it backward compatible, a macro can be used in Python 3.7 using PyDict_GetItem() and Py_XINCREF(). Pseudo-code:

static PyObject*
PyDict_GetItemRef(PyObject *dict, PyObject *key)
{
    PyObject *value = PyDict_GetItem(dict, key);
    Py_XINCREF(value);
    return value;
}

Option questions:

Forward compatibility with Python 3.8 and newer

C extensions have to be modified to become compatible with the new C API, because of removed functions for example.

Open question: support Python 2?

Would it be possible to provide a basic support of Python 2 in the new C API?

Open question: how to install the compatibility layers

pip install something?


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4