# Limited C API: implement Py\_INCREF() and Py\_DECREF() as function calls

**URL:** <https://discuss.python.org/t/limited-c-api-implement-py-incref-and-py-decref-as-function-calls/27592>\
**Category:** C API\
**Created:** [June 9, 2023, 10:26am UTC](https://discuss.python.org/t/limited-c-api-implement-py-incref-and-py-decref-as-function-calls/27592 "2023-06-09T10:26:16Z")\
**Posts on this page:** 1\
**Showing post:** 22

<div class="post-metadata">

**Author:** ![vstinner](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/vstinner/32/15130_2.png) [@vstinner](https://discuss.python.org/u/vstinner)\
**Post date:** [November 16, 2026, 4:50pm UTC](https://discuss.python.org/t/limited-c-api-implement-py-incref-and-py-decref-as-function-calls/27592/22 "2026-11-16T16:50:29Z")

</div>

The problem is not fully fixed: C extensions built with limited C API version 3.11 and newer convert immortal objects (such as `None`) to mortal objects (!): it should never happen, and because of that, it introduces multiple nasty bugs. See [issue gh-158401](https://github.com/python/cpython/issues/158401).

I wrote [PR gh-162120](https://github.com/python/cpython/pull/162120) to implemented `Py_INCREF()`/`Py_DECREF()` as function calls on all limited C API versions. So if you use Python 3.16 and target an older limited C API version, the change should work around this “objects de-immortalized” issue.

My PR only fix the issue if you use Python 3.16 to build your C extensions. It doesn’t cover all cases.

---

_[View the full topic](https://discuss.python.org/t/limited-c-api-implement-py-incref-and-py-decref-as-function-calls/27592)._
