Skip to content

Commit 61e54c2

Browse files
authored
REF: remove is_simple_frame from json code (#54662)
1 parent 3060df9 commit 61e54c2

File tree

1 file changed

+6
-40
lines changed

1 file changed

+6
-40
lines changed

pandas/_libs/src/vendored/ujson/python/objToJSON.c

+6-40
Original file line numberDiff line numberDiff line change
@@ -262,21 +262,6 @@ static Py_ssize_t get_attr_length(PyObject *obj, char *attr) {
262262
return ret;
263263
}
264264

265-
static int is_simple_frame(PyObject *obj) {
266-
PyObject *mgr = PyObject_GetAttrString(obj, "_mgr");
267-
if (!mgr) {
268-
return 0;
269-
}
270-
int ret;
271-
if (PyObject_HasAttrString(mgr, "blocks")) {
272-
ret = (get_attr_length(mgr, "blocks") <= 1);
273-
} else {
274-
ret = 0;
275-
}
276-
277-
Py_DECREF(mgr);
278-
return ret;
279-
}
280265

281266
static npy_int64 get_long_attr(PyObject *o, const char *attr) {
282267
// NB we are implicitly assuming that o is a Timedelta or Timestamp, or NaT
@@ -1140,15 +1125,8 @@ int DataFrame_iterNext(JSOBJ obj, JSONTypeContext *tc) {
11401125
GET_TC(tc)->itemValue = PyObject_GetAttrString(obj, "index");
11411126
} else if (index == 2) {
11421127
memcpy(GET_TC(tc)->cStr, "data", sizeof(char) * 5);
1143-
if (is_simple_frame(obj)) {
1144-
GET_TC(tc)->itemValue = PyObject_GetAttrString(obj, "values");
1145-
if (!GET_TC(tc)->itemValue) {
1146-
return 0;
1147-
}
1148-
} else {
1149-
Py_INCREF(obj);
1150-
GET_TC(tc)->itemValue = obj;
1151-
}
1128+
Py_INCREF(obj);
1129+
GET_TC(tc)->itemValue = obj;
11521130
} else {
11531131
return 0;
11541132
}
@@ -1756,22 +1734,10 @@ void Object_beginTypeContext(JSOBJ _obj, JSONTypeContext *tc) {
17561734
return;
17571735
}
17581736

1759-
if (is_simple_frame(obj)) {
1760-
pc->iterBegin = NpyArr_iterBegin;
1761-
pc->iterEnd = NpyArr_iterEnd;
1762-
pc->iterNext = NpyArr_iterNext;
1763-
pc->iterGetName = NpyArr_iterGetName;
1764-
1765-
pc->newObj = PyObject_GetAttrString(obj, "values");
1766-
if (!pc->newObj) {
1767-
goto INVALID;
1768-
}
1769-
} else {
1770-
pc->iterBegin = PdBlock_iterBegin;
1771-
pc->iterEnd = PdBlock_iterEnd;
1772-
pc->iterNext = PdBlock_iterNext;
1773-
pc->iterGetName = PdBlock_iterGetName;
1774-
}
1737+
pc->iterBegin = PdBlock_iterBegin;
1738+
pc->iterEnd = PdBlock_iterEnd;
1739+
pc->iterNext = PdBlock_iterNext;
1740+
pc->iterGetName = PdBlock_iterGetName;
17751741
pc->iterGetValue = NpyArr_iterGetValue;
17761742

17771743
if (enc->outputFormat == VALUES) {

0 commit comments

Comments
 (0)