[C API] Add PyType_Lookup() function

Feature or enhancement

There is a private _PyType_Lookup() function which is used by 27 projects of the PyPI top 15,000 projects:

  • Nuitka (2.7.16)
  • ansys_pythonnet-3.1.0rc6
  • casadi (3.7.2)
  • catboost (1.2.8)
  • cvxpy (1.7.2)
  • cvxpy_base (1.7.2)
  • cython (3.1.4)
  • extensionclass (6.0)
  • gamsapi (51.1.0)
  • gdal (3.11.4)
  • gevent (25.9.1)
  • htseq (2.0.9)
  • ihm (2.7)
  • m2crypto (0.45.1)
  • mecab-ko (1.0.1)
  • mecab_python3 (1.0.10)
  • msgspec (0.19.0)
  • mupdf (1.21.1.20230112.1504)
  • mypy (1.18.2)
  • pybind11 (3.0.1)
  • pycuda (2025.1.2)
  • pygdal (3.6.4.11)
  • pygraphviz (1.14)
  • python_crfsuite (0.9.11)
  • pythonnet (3.0.5)
  • sentencepiece (0.2.1)
  • yappi (1.6.10)

I propose to make the function public.

Linked PRs