-
-
Notifications
You must be signed in to change notification settings - Fork 51
Numpy HPy migration notes: blockers and concerns
Stepan Sindelar edited this page May 5, 2022
·
7 revisions
- numpy uses the
METH_FASTCALL | METH_KEYWORDS
convention and has its own argument parser for that - metaclass support for heap types is missing in CPython
-
tp_vectorcall
is not supposed to be used for heap types - numpy accesses
tp_
slots directly. Edit: not an issue since numpy is moving away from that.-
to compare them (We could provide
bool HPyType_CheckSlot(HPyContext*, HPy, HPyDef expected)
) - to read things like
tp_name
,tp_base
,tp_dict
- for fast paths bypassing some CPython logic (e.g.: getting attribute without raising exception if missing)
-
to compare them (We could provide
-
PyArrayObject*
->HPy
removes type information and type checking- Numpy uses the struct types in many helper/infrastructure functions, changing all those to
HPy
removes the type information, which makes the code less pleasant to work with and more error prone - Sometimes it is desirable to pass around additional argument for
PyArrayObject*
alongside theHPy
handle if the struct was already retrieved - this is cumbersome
- Numpy uses the struct types in many helper/infrastructure functions, changing all those to
- Some ideas:
- generate additional struct that holds both the handle and the struct and helper methods for it, e.g.,
typedef struct { HPy handle; PyArrayObject *data; } HPyArray;
- generate additional struct to wrap just the handle to "attach" type information to it + generate conversion helpers
- depending on whether we see similar patters in other packages, this could be just infrastructure in numpy port codebase or provided by HPy
- generate additional struct that holds both the handle and the struct and helper methods for it, e.g.,
- 5 September 2024
- 4 April 2024
- 7 March 2024
- 1 February 2024
- 11 January 2024
- 7 December 2023
- 9 November 2023
- 5 October 2023
- 14 September 2023
- 3 August 2023
- 6 July 2023
- 1 June 2023
- 4 May 2023
- 13 April 2023
- 2 March 2023
- 2 February 2023
- 12 January 2023
- 1 December 2022
- 3 November 2022
- 6 October 2022
- 8 September 2022
- 4 August 2022
- 7 July 2022
- 2 June 2022
- 5 May 2022
- 7 April 2022
- 3 March 2022
- 3 February 2022
- 13 January 2022
- 2 December 2021
- 4 November 2021
- 7 October 2021
- 2 September 2021
- 12 August 2021
- 8 July 2021
- 6 May 2021
- 4 March 2021
- 7 January 2021
- 3 December 2020
- 5 November 2020