Skip to content

CLN: Some code cleanups in pandas/_libs/parsers.pyx #32369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Mar 16, 2020
27 changes: 5 additions & 22 deletions pandas/_libs/parsers.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1596,8 +1596,6 @@ cdef _categorical_convert(parser_t *parser, int64_t col,
cdef _to_fw_string(parser_t *parser, int64_t col, int64_t line_start,
int64_t line_end, int64_t width):
cdef:
Py_ssize_t i
coliter_t it
const char *word = NULL
char *data
ndarray result
Expand Down Expand Up @@ -1642,15 +1640,11 @@ cdef _try_double(parser_t *parser, int64_t col,
bint na_filter, kh_str_starts_t *na_hashset, object na_flist):
cdef:
int error, na_count = 0
Py_ssize_t i, lines
coliter_t it
const char *word = NULL
char *p_end
Py_ssize_t lines
float64_t *data
float64_t NA = na_values[np.float64]
kh_float64_t *na_fset
ndarray result
khiter_t k
bint use_na_flist = len(na_flist) > 0

lines = line_end - line_start
Expand Down Expand Up @@ -1685,7 +1679,7 @@ cdef inline int _try_double_nogil(parser_t *parser,
coliter_t it
const char *word = NULL
char *p_end
khiter_t k, k64
khiter_t k64

na_count[0] = 0
coliter_setup(&it, parser, col, line_start)
Expand Down Expand Up @@ -1748,11 +1742,10 @@ cdef _try_uint64(parser_t *parser, int64_t col,
bint na_filter, kh_str_starts_t *na_hashset):
cdef:
int error
Py_ssize_t i, lines
Py_ssize_t lines
coliter_t it
uint64_t *data
ndarray result
khiter_t k
uint_state state

lines = line_end - line_start
Expand Down Expand Up @@ -1822,13 +1815,11 @@ cdef _try_int64(parser_t *parser, int64_t col,
bint na_filter, kh_str_starts_t *na_hashset):
cdef:
int error, na_count = 0
Py_ssize_t i, lines
Py_ssize_t lines
coliter_t it
int64_t *data
ndarray result

int64_t NA = na_values[np.int64]
khiter_t k

lines = line_end - line_start
result = np.empty(lines, dtype=np.int64)
Expand Down Expand Up @@ -1856,7 +1847,6 @@ cdef inline int _try_int64_nogil(parser_t *parser, int64_t col,
Py_ssize_t i, lines = line_end - line_start
coliter_t it
const char *word = NULL
khiter_t k

na_count[0] = 0
coliter_setup(&it, parser, col, line_start)
Expand Down Expand Up @@ -1892,9 +1882,7 @@ cdef _try_bool_flex(parser_t *parser, int64_t col,
const kh_str_starts_t *false_hashset):
cdef:
int error, na_count = 0
Py_ssize_t i, lines
coliter_t it
const char *word = NULL
Py_ssize_t lines
uint8_t *data
ndarray result

Expand Down Expand Up @@ -1926,7 +1914,6 @@ cdef inline int _try_bool_flex_nogil(parser_t *parser, int64_t col,
Py_ssize_t i, lines = line_end - line_start
coliter_t it
const char *word = NULL
khiter_t k

na_count[0] = 0
coliter_setup(&it, parser, col, line_start)
Expand Down Expand Up @@ -1981,10 +1968,8 @@ cdef kh_str_starts_t* kset_from_list(list values) except NULL:
# caller takes responsibility for freeing the hash table
cdef:
Py_ssize_t i
khiter_t k
kh_str_starts_t *table
int ret = 0

object val

table = kh_init_str_starts()
Expand Down Expand Up @@ -2012,7 +1997,6 @@ cdef kh_str_starts_t* kset_from_list(list values) except NULL:
cdef kh_float64_t* kset_float64_from_list(values) except NULL:
# caller takes responsibility for freeing the hash table
cdef:
Py_ssize_t i
khiter_t k
kh_float64_t *table
int ret = 0
Expand Down Expand Up @@ -2150,7 +2134,6 @@ cdef _apply_converter(object f, parser_t *parser, int64_t col,
int64_t line_start, int64_t line_end,
char* c_encoding):
cdef:
int error
Py_ssize_t i, lines
coliter_t it
const char *word = NULL
Expand Down