hpyproject / hpy

HPy: a better API for Python
https://hpyproject.org
MIT License
1.02k stars 52 forks source link

Introduce HPyType_GetName and HPyType_IsSubtype. #410

Closed fangerer closed 1 year ago

fangerer commented 1 year ago

These new API functions are needed for Numpy/HPy. I recommend reviewing commit by commit.

The equivalent functions in CPython take PyTypeObject * as arguments which we cannot do in HPy but as we already do with HPy_TypeCheck, we check that in the debug mode.

In case of HPyType_GetName, I decided to return the type's name as a UTF-8 encoded C string instead of returning a Unicode object as CPython does. Reason: If a C extension wants to retrieve the name of a type, I assume it will work with the name in C. Also, there is a perfect option to get the type's name as Unicode object, which is: HPy_GetAttr_s(ctx, type, "__name__").

This PR also contains a little doc improvement: The HPy API function index is now sorted alphabetically.

mattip commented 1 year ago

LGTM, in it goes