hpyproject / hpy

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

Should we have HPyDict_GetItem #404

Open fangerer opened 1 year ago

fangerer commented 1 year ago

In February 2023's dev call, we had some discussion about if we should have HPyDict_GetItem (similar to PyDict_GetItem).

PyDict_GetItem has following semantic differences compared to the generic PyObject_GetItem:

Arguments for having HPyDict_GetItem:

Arguments against:

@hodgestar made two suggestions:

  1. If the API is used for performance, the runtime should do the necessary optimizations internally. However, since the semantic is also a bit different, I think we at least need something like HPyBuiltin_GetItem (i.e. don't do an attribute lookup but access storage directly if it is an appropriate built-in type).
  2. If the API is used because of the error behavior, we could introduce HPy_GetItem_NoError to make the behavior clear.