From 3d321562b4cc1b85e821c238632f73802c7c9e01 Mon Sep 17 00:00:00 2001 From: Nicolas Cornu Date: Wed, 20 Nov 2024 14:40:26 +0100 Subject: [PATCH 1/2] Use nb::make_tuple --- src/nrnpython/nrnpy_p2h.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/nrnpython/nrnpy_p2h.cpp b/src/nrnpython/nrnpy_p2h.cpp index cde00ef0a2..564446dbf5 100644 --- a/src/nrnpython/nrnpy_p2h.cpp +++ b/src/nrnpython/nrnpy_p2h.cpp @@ -428,9 +428,7 @@ static Object* callable_with_args(Object* ho, int narg) { } } - auto r = nb::steal(PyTuple_New(2)); - PyTuple_SetItem(r.ptr(), 1, args.release().ptr()); - PyTuple_SetItem(r.ptr(), 0, po.release().ptr()); + nb::tuple r = nb::make_tuple(po, args); Object* hr = nrnpy_po2ho(r.release().ptr()); @@ -885,9 +883,7 @@ static Object* py_alltoall_type(int size, int type) { sdispl = mk_displ(scnt.data()); rdispl = mk_displ(rcnt); if (size < 0) { - pdest = PyTuple_New(2); - PyTuple_SetItem(pdest, 0, Py_BuildValue("l", (long) sdispl[np])); - PyTuple_SetItem(pdest, 1, Py_BuildValue("l", (long) rdispl[np])); + pdest = nb::make_tuple(sdispl[np], rdispl[np]).release().ptr() delete[] sdispl; delete[] rcnt; delete[] rdispl; From 0061929a1306e39510deae36decf6959a656e1e5 Mon Sep 17 00:00:00 2001 From: Nicolas Cornu Date: Wed, 20 Nov 2024 15:52:20 +0100 Subject: [PATCH 2/2] boho --- src/nrnpython/nrnpy_p2h.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nrnpython/nrnpy_p2h.cpp b/src/nrnpython/nrnpy_p2h.cpp index 564446dbf5..9267abdd2b 100644 --- a/src/nrnpython/nrnpy_p2h.cpp +++ b/src/nrnpython/nrnpy_p2h.cpp @@ -883,7 +883,7 @@ static Object* py_alltoall_type(int size, int type) { sdispl = mk_displ(scnt.data()); rdispl = mk_displ(rcnt); if (size < 0) { - pdest = nb::make_tuple(sdispl[np], rdispl[np]).release().ptr() + pdest = nb::make_tuple(sdispl[np], rdispl[np]).release().ptr(); delete[] sdispl; delete[] rcnt; delete[] rdispl;