@@ -56,41 +56,45 @@ PyArray_typeinfo(HPyContext *ctx,
56
56
char typechar , int typenum , int nbits , int align ,
57
57
HPy type_obj )
58
58
{
59
- HPyStructSequenceBuilder entry = HPyStructSequenceBuilder_New (ctx , PyArray_typeinfoType );
60
- HPyStructSequenceBuilder_Set_i (ctx , entry , 0 , typechar );
61
- HPyStructSequenceBuilder_Set_i (ctx , entry , 1 , typenum );
62
- HPyStructSequenceBuilder_Set_i (ctx , entry , 2 , nbits );
63
- HPyStructSequenceBuilder_Set_i (ctx , entry , 3 , align );
64
- HPyStructSequenceBuilder_Set (ctx , entry , 4 , type_obj );
65
-
66
- if (HPyErr_Occurred (ctx )) {
67
- HPyStructSequenceBuilder_Cancel (ctx , entry );
59
+ HPy types [] = {
60
+ HPyLong_FromLong (ctx , typechar ),
61
+ HPyLong_FromLong (ctx , typenum ),
62
+ HPyLong_FromLong (ctx , nbits ),
63
+ HPyLong_FromLong (ctx , align ),
64
+ type_obj
65
+ };
66
+ HPy entry = HPyStructSequence_New (ctx , PyArray_typeinfoType , 5 , types );
67
+ for (int i = 0 ; i < 4 ; i ++ )
68
+ HPy_Close (ctx , types [i ]);
69
+
70
+ if (HPy_IsNull (entry )) {
68
71
return HPy_NULL ;
69
72
}
70
-
71
- return HPyStructSequenceBuilder_Build (ctx , entry , PyArray_typeinfoType );
73
+ return entry ;
72
74
}
73
75
74
76
NPY_NO_EXPORT HPy
75
77
PyArray_typeinforanged (HPyContext * ctx ,
76
78
char typechar , int typenum , int nbits , int align ,
77
79
HPy max , HPy min , HPy type_obj )
78
80
{
79
- HPyStructSequenceBuilder entry = HPyStructSequenceBuilder_New (ctx , PyArray_typeinforangedType );
80
- HPyStructSequenceBuilder_Set_i (ctx , entry , 0 , typechar );
81
- HPyStructSequenceBuilder_Set_i (ctx , entry , 1 , typenum );
82
- HPyStructSequenceBuilder_Set_i (ctx , entry , 2 , nbits );
83
- HPyStructSequenceBuilder_Set_i (ctx , entry , 3 , align );
84
- HPyStructSequenceBuilder_Set (ctx , entry , 4 , max );
85
- HPyStructSequenceBuilder_Set (ctx , entry , 5 , min );
86
- HPyStructSequenceBuilder_Set (ctx , entry , 6 , type_obj );
87
-
88
- if (HPyErr_Occurred (ctx )) {
89
- HPyStructSequenceBuilder_Cancel (ctx , entry );
81
+ HPy types [] = {
82
+ HPyLong_FromLong (ctx , typechar ),
83
+ HPyLong_FromLong (ctx , typenum ),
84
+ HPyLong_FromLong (ctx , nbits ),
85
+ HPyLong_FromLong (ctx , align ),
86
+ max ,
87
+ min ,
88
+ type_obj
89
+ };
90
+ HPy entry = HPyStructSequence_New (ctx , PyArray_typeinforangedType , 7 , types );
91
+ for (int i = 0 ; i < 4 ; i ++ )
92
+ HPy_Close (ctx , types [i ]);
93
+
94
+ if (HPy_IsNull (entry )) {
90
95
return HPy_NULL ;
91
96
}
92
-
93
- return HPyStructSequenceBuilder_Build (ctx , entry , PyArray_typeinforangedType );
97
+ return entry ;
94
98
}
95
99
96
100
/* Python version needed for older PyPy */
0 commit comments