TL;DR Is it possible to use C code to implement the (un)pickling of an type written in a C extension, as it was written in _pickle.c?

Long explaining: I'm trying to create a C extension for frozendict. For simplicity, first I wrote it in CPython, then I started to move it in a C extension. It seems to work, but I have to move the code I wrote in _pickle.c and pickle.py in the C extension. Is it possible, or I have to create a slower `__reduce_ex__` method that simply converts it to dict?

This is, for example, the C code for pickling frozendict in _pickle.c:
https://github.com/Marco-Sulla/cpython/blob/41a640a947c36007e56bbc28f362c261110d2001/Modules/_pickle.c#L3370