10000 Pull request #42: Migrate promote_and_get_ufuncimpl · hpyproject/numpy-hpy@6eec2a4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6eec2a4

Browse files
committed
Pull request numpy#42: Migrate promote_and_get_ufuncimpl
Merge in ~STEPAN.SINDELAR_ORACLE.COM/numpy-hpy from fa/promote_and_get_ufuncimpl to labs-hpy-port * commit '2c7e4ce99eb5a98f24a024180004dfd0efacf077': Use hpy_promote_and_get_ufuncimpl in ufunc_hpy_generic_fastcall Migrate function legacy_promote_using_legacy_type_resolver Migrate function raise_no_loop_found_error Migrate function promote_and_get_ufuncimpl Add empty function hpy_legacy_promote_using_legacy_type_resolver Migrate function promote_and_get_info_and_ufuncimpl Add HPyArrayIdentityHash_(Get/Set)Item
2 parents 847badc + 2c7e4ce commit 6eec2a4

File tree

7 files changed

+347
-140
lines changed

7 files changed

+347
-140
lines changed

numpy/core/src/common/npy_hashtable.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include "templ_common.h"
1616
#include "npy_hashtable.h"
17+
#include "hpy_utils.h"
1718

1819

1920

@@ -218,3 +219,28 @@ PyArrayIdentityHash_GetItem(PyArrayIdentityHash const *tb, PyObject *const *key)
218219
{
219220
return find_item(tb, key)[0];
220221
}
222+
223+
NPY_NO_EXPORT int
224+
HPyArrayIdentityHash_SetItem(HPyContext *ctx, PyArrayIdentityHash *tb,
225+
HPy const *key, HPy value, int replace)
226+
{
227+
CAPI_WARN("HPyArrayIdentityHash_SetItem");
228+
PyObject **py_key = HPy_AsPyObjectArray(ctx, (HPy *)key, tb->key_len);
229+
PyObject *py_value = HPy_AsPyObject(ctx, value);
230+
int res = PyArrayIdentityHash_SetItem(tb, py_key, py_value, replace);
231+
Py_XDECREF(py_value);
232+
HPy_DecrefAndFreeArray(ctx, py_key, tb->key_len);
233+
return res;
234+
}
235+
236+
NPY_NO_EXPORT HPy
237+
HPyArrayIdentityHash_GetItem(HPyContext *ctx, PyArrayIdentityHash const *tb, HPy const *key)
238+
{
239+
CAPI_WARN("HPyArrayIdentityHash_GetItem");
240+
PyObject **py_key = HPy_AsPyObjectArray(ctx, (HPy *)key, tb->key_len);
241+
PyObject *py_res = PyArrayIdentityHash_GetItem(tb, py_key);
242+
HPy res = HPy_FromPyObject(ctx, py_res);
243+
Py_XDECREF(py_res);
244+
HPy_DecrefAndFreeArray(ctx, py_key, tb->key_len);
245+
return res;
246+
}

numpy/core/src/common/npy_hashtable.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,11 @@ PyArrayIdentityHash_New(int key_len);
2929
NPY_NO_EXPORT void
3030
PyArrayIdentityHash_Dealloc(PyArrayIdentityHash *tb);
3131

32+
NPY_NO_EXPORT int
33+
H 55A2 PyArrayIdentityHash_SetItem(HPyContext *ctx, PyArrayIdentityHash *tb,
34+
HPy const *key, HPy value, int replace);
35+
36+
NPY_NO_EXPORT HPy
37+
HPyArrayIdentityHash_GetItem(HPyContext *ctx, PyArrayIdentityHash const *tb, HPy const *key);
38+
3239
#endif /* NUMPY_CORE_SRC_COMMON_NPY_NPY_HASHTABLE_H_ */

0 commit comments

Comments
 (0)
0