@@ -1306,14 +1306,7 @@ char **NpyArr_encodeLabels(PyArrayObject *labels, PyObjectEncoder *enc,
1306
1306
NPY_DATETIMEUNIT dateUnit = NPY_FR_ns ;
1307
1307
if (PyTypeNum_ISDATETIME (type_num )) {
1308
1308
is_datetimelike = 1 ;
1309
- PyArray_VectorUnaryFunc * castfunc =
1310
- PyArray_GetCastFunc (PyArray_DescrFromType (type_num ), NPY_INT64 );
1311
- if (!castfunc ) {
1312
- PyErr_Format (PyExc_ValueError ,
1313
- "Cannot cast numpy dtype %d to long" ,
1314
- enc -> npyType );
1315
- }
1316
- castfunc (dataptr , & i8date , 1 , NULL , NULL );
1309
+ i8date = * (npy_int64 * )dataptr ;
1317
1310
dateUnit = get_datetime_metadata_from_dtype (dtype ).base ;
1318
1311
} else if (PyDate_Check (item ) || PyDelta_Check (item )) {
1319
1312
is_datetimelike = 1 ;
@@ -1453,13 +1446,8 @@ void Object_beginTypeContext(JSOBJ _obj, JSONTypeContext *tc) {
1453
1446
1454
1447
if (PyTypeNum_ISDATETIME (enc -> npyType )) {
1455
1448
int64_t longVal ;
1456
- PyArray_VectorUnaryFunc * castfunc =
1457
- PyArray_GetCastFunc (PyArray_DescrFromType (enc -> npyType ), NPY_INT64 );
1458
- if (!castfunc ) {
1459
- PyErr_Format (PyExc_ValueError , "Cannot cast numpy dtype %d to long" ,
1460
- enc -> npyType );
1461
- }
1462
- castfunc (enc -> npyValue , & longVal , 1 , NULL , NULL );
1449
+
1450
+ longVal = * (npy_int64 * )enc -> npyValue ;
1463
1451
if (longVal == get_nat ()) {
1464
1452
tc -> type = JT_NULL ;
1465
1453
} else {
0 commit comments