@@ -317,20 +317,34 @@ stringdtype_get_clear_loop(void *NPY_UNUSED(traverse_context),
317
317
}
318
318
319
319
static int
320
- stringdtype_fill_zero_value (PyArrayObject * arr )
320
+ stringdtype_fill_zero_loop (void * NPY_UNUSED (traverse_context ),
321
+ PyArray_Descr * NPY_UNUSED (descr ), char * data ,
322
+ npy_intp size , npy_intp stride ,
323
+ NpyAuxData * NPY_UNUSED (auxdata ))
321
324
{
322
- char * buf = PyArray_DATA (arr );
323
- npy_intp sz = PyArray_SIZE (arr );
324
- int elsize = PyArray_DESCR (arr )-> elsize ;
325
-
326
- for (npy_intp i = 0 ; i < sz ; i ++ ) {
327
- if (ssnewlen ("" , 0 , (ss * )(buf + i * elsize )) < 0 ) {
325
+ while (size -- ) {
326
+ if (ssnewlen ("" , 0 , (ss * )(data )) < 0 ) {
328
327
return -1 ;
329
328
}
329
+ data += stride ;
330
330
}
331
331
return 0 ;
332
332
}
333
333
334
+ static int
335
+ stringdtype_get_fill_zero_loop (void * NPY_UNUSED (traverse_context ),
336
+ PyArray_Descr * NPY_UNUSED (descr ),
337
+ int NPY_UNUSED (aligned ),
338
+ npy_intp NPY_UNUSED (fixed_stride ),
339
+ traverse_loop_function * * out_loop ,
340
+ NpyAuxData * * NPY_UNUSED (out_auxdata ),
341
+ NPY_ARRAYMETHOD_FLAGS * flags )
342
+ {
343
+ * flags = NPY_METH_NO_FLOATINGPOINT_ERRORS ;
344
+ * out_loop = & stringdtype_fill_zero_loop ;
345
+ return 0 ;
346
+ }
347
+
334
348
static PyType_Slot StringDType_Slots [] = {
335
349
{NPY_DT_common_instance , & common_instance },
336
350
{NPY_DT_common_dtype , & common_dtype },
@@ -344,7 +358,7 @@ static PyType_Slot StringDType_Slots[] = {
344
358
{NPY_DT_PyArray_ArrFuncs_argmax , & argmax },
345
359
{NPY_DT_PyArray_ArrFuncs_argmin , & argmin },
346
360
{NPY_DT_get_clear_loop , & stringdtype_get_clear_loop },
347
- {NPY_DT_fill_zero_value , & stringdtype_fill_zero_value },
361
+ {NPY_DT_get_fill_zero_loop , & stringdtype_get_fill_zero_loop },
348
362
{0 , NULL }};
349
363
350
364
static PyObject *
0 commit comments