hpyproject / hpy

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

Introduce HPy_DelAttr(_s) and HPy_DelItem(_i/_s) #372

Closed fangerer closed 1 year ago

fangerer commented 1 year ago

This PR add a bunch of new API functions for deleting items and attributes (resolves issue #369).

Similar to CPython, functions HPy_DelAttr(_s) are just inline helper functions that use HPy_SetAttr(_s) and pass HPy_NULL as value.

For HPy_DelItem(_i/_s), I followed the same strategy as we did for HPy_SetItem(_i/_s).

fangerer commented 1 year ago

@antocuni

sometimes it is hard to distinguish whether we are testing HPy (i.e. "HPy_DelAttr" should delete the attribute) or the underlying python implementation

Agreed. One source for this problem is that we still try to map HPy API to C API if we can. We should probably define the semantics separately for HPy but then it might happen that we can no longer directly map to a C API.

the tests have a lot a duplication

We could use a template for those kinds of tests and replace the types. I'm also fine with merging them.

fangerer commented 1 year ago

@hodgestar please do another review round. I've addressed all your comments.

antocuni commented 1 year ago

Agreed. One source for this problem is that we still try to map HPy API to C API if we can. We should probably define the semantics separately for HPy but then it might happen that we can no longer directly map to a C API.

I'm not sure to understand. Even if we say that HPy_DelItem maps to PyObject_DelItem, there is no point in testing all the possible combinations of items, is there?