Open rlamy opened 2 years ago
For CPython, this boils down to whether to use Py_INCREF
or Py_XINCREF
here:
https://github.com/hpyproject/hpy/blob/c7d36aa3e08c32a49703b3afd22ac1bdc932f2aa/hpy/devel/include/hpy/cpython/misc.h#L219-L224
I would be nice to have the safest API, but at the same time introducing XLoad
could give some performance benefits.
A quick way to check whether it matters nowadays is e.g. to take an arbitrary C extension, replace all Py_INCREF
with Py_XINCREF
, recompile and see if/how much slower it becomes.
This should give us a rough idea of the performance costs
I think this relates to #297
Currently,
HPyField_Load()
segfaults when the field isHPyField_NULL
, which is annoying to handle. I see 2 options:HPyField_Load
should returnHPy_NULL
for a null field.HPyField_Load
unchanged, but introduceHPyField_XLoad
that behaves like the above.