@@ -29,6 +29,7 @@ from cpython.exc cimport (
29
29
PyErr_Fetch,
30
30
PyErr_Occurred,
31
31
)
32
+ from cpython.long cimport PyLong_FromString
32
33
from cpython.object cimport PyObject
33
34
from cpython.ref cimport (
34
35
Py_INCREF,
@@ -1081,9 +1082,8 @@ cdef class TextReader:
1081
1082
np.dtype(" object" ), i, start, end, 0 ,
1082
1083
0 , na_hashset, na_fset)
1083
1084
except OverflowError :
1084
- col_res, na_count = self ._convert_with_dtype(
1085
- np.dtype(" object" ), i, start, end, na_filter,
1086
- 0 , na_hashset, na_fset)
1085
+ col_res, na_count = _try_pylong(self .parser, i, start,
1086
+ end, na_filter, na_hashset)
1087
1087
1088
1088
if col_res is not None :
1089
1089
break
@@ -1873,6 +1873,36 @@ cdef int _try_int64_nogil(parser_t *parser, int64_t col,
1873
1873
1874
1874
return 0
1875
1875
1876
+ cdef _try_pylong(parser_t * parser, Py_ssize_t col,
1877
+ int64_t line_start, int64_t line_end,
1878
+ bint na_filter, kh_str_starts_t * na_hashset):
1879
+ cdef:
1880
+ int na_count = 0
1881
+ Py_ssize_t lines
1882
+ coliter_t it
1883
+ const char * word = NULL
1884
+ ndarray[object ] result
1885
+ object NA = na_values[np.object_]
1886
+
1887
+ lines = line_end - line_start
1888
+ result = np.empty(lines, dtype = object )
1889
+ coliter_setup(& it, parser, col, line_start)
1890
+
1891
+ for i in range (lines):
1892
+ COLITER_NEXT(it, word)
1893
+ if na_filter and kh_get_str_starts_item(na_hashset, word):
1894
+ # in the hash table
1895
+ na_count += 1
1896
+ result[i] = NA
1897
+ continue
1898
+
1899
+ py_int = PyLong_FromString(word, NULL , 10 )
1900
+ if py_int is None :
1901
+ raise ValueError (" Invalid integer " , word)
1902
+ result[i] = py_int
1903
+
1904
+ return result, na_count
1905
+
1876
1906
1877
1907
# -> tuple[ndarray[bool], int]
1878
1908
cdef _try_bool_flex(parser_t * parser, int64_t col,
0 commit comments