@@ -1280,13 +1280,7 @@ char **NpyArr_encodeLabels(PyArrayObject *labels, PyObjectEncoder *enc,
1280
1280
NPY_DATETIMEUNIT dateUnit = NPY_FR_ns ;
1281
1281
if (PyTypeNum_ISDATETIME (type_num )) {
1282
1282
is_datetimelike = 1 ;
1283
- PyArray_VectorUnaryFunc * castfunc =
1284
- PyArray_GetCastFunc (PyArray_DescrFromType (type_num ), NPY_INT64 );
1285
- if (!castfunc ) {
1286
- PyErr_Format (PyExc_ValueError , "Cannot cast numpy dtype %d to long" ,
1287
- enc -> npyType );
1288
- }
1289
- castfunc (dataptr , & i8date , 1 , NULL , NULL );
1283
+ i8date = * (npy_int64 * )dataptr ;
1290
1284
dateUnit = get_datetime_metadata_from_dtype (dtype ).base ;
1291
1285
} else if (PyDate_Check (item ) || PyDelta_Check (item )) {
1292
1286
is_datetimelike = 1 ;
@@ -1425,13 +1419,8 @@ void Object_beginTypeContext(JSOBJ _obj, JSONTypeContext *tc) {
1425
1419
1426
1420
if (PyTypeNum_ISDATETIME (enc -> npyType )) {
1427
1421
int64_t longVal ;
1428
- PyArray_VectorUnaryFunc * castfunc =
1429
- PyArray_GetCastFunc (PyArray_DescrFromType (enc -> npyType ), NPY_INT64 );
1430
- if (!castfunc ) {
1431
- PyErr_Format (PyExc_ValueError , "Cannot cast numpy dtype %d to long" ,
1432
- enc -> npyType );
1433
- }
1434
- castfunc (enc -> npyValue , & longVal , 1 , NULL , NULL );
1422
+
1423
+ longVal = * (npy_int64 * )enc -> npyValue ;
1435
1424
if (longVal == get_nat ()) {
1436
1425
tc -> type = JT_NULL ;
1437
1426
} else {
0 commit comments