# Adding C API for use in tp\_traverse

**URL:** <https://discuss.python.org/t/adding-c-api-for-use-in-tp-traverse/105331>\
**Category:** C API\
**Created:** [December 17, 2025, 1:48pm UTC](https://discuss.python.org/t/adding-c-api-for-use-in-tp-traverse/105331 "2025-12-17T13:48:16Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![colesbury](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/colesbury/32/28031_2.png) [@colesbury](https://discuss.python.org/u/colesbury)\
**Post date:** [December 22, 2025, 9:35pm UTC](https://discuss.python.org/t/adding-c-api-for-use-in-tp-traverse/105331/11 "2025-12-22T21:35:30Z")

</div>

> [@encukou](#):
>
> But the main issue is the borrowed references.

I think that’s just `PyType_GetBaseByToken` and `PyType_GetModuleByToken`. It seems pretty rare to need to call them from a `tp_traverse` handler. If really necessary, I think you can work around that in extensions by calling other APIs.

If there were a few extensions that would make use of it, I’d say to add those two with `_Borrow` or `_GCSafe` suffixes, but I’m not sure it’s worth it right now.

---

_[View the full topic](https://discuss.python.org/t/adding-c-api-for-use-in-tp-traverse/105331)._
