@@ -1306,14 +1306,7 @@ char **NpyArr_encodeLabels(PyArrayObject *labels, PyObjectEncoder *enc,
13061306 NPY_DATETIMEUNIT dateUnit = NPY_FR_ns ;
13071307 if (PyTypeNum_ISDATETIME (type_num )) {
13081308 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 ;
13171310 dateUnit = get_datetime_metadata_from_dtype (dtype ).base ;
13181311 } else if (PyDate_Check (item ) || PyDelta_Check (item )) {
13191312 is_datetimelike = 1 ;
@@ -1453,13 +1446,8 @@ void Object_beginTypeContext(JSOBJ _obj, JSONTypeContext *tc) {
14531446
14541447 if (PyTypeNum_ISDATETIME (enc -> npyType )) {
14551448 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 ;
14631451 if (longVal == get_nat ()) {
14641452 tc -> type = JT_NULL ;
14651453 } else {
0 commit comments