Skip to content

PERF: read_csv macro updates #52632

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 6 commits into from
Apr 14, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pandas/_libs/src/parser/tokenizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -664,9 +664,7 @@ static int parser_buffer_bytes(parser_t *self, size_t nbytes,
((!self->delim_whitespace && c == ' ' && self->skipinitialspace))

// applied when in a field
#define IS_DELIMITER(c) \
((!self->delim_whitespace && c == self->delimiter) || \
(self->delim_whitespace && isblank(c)))
#define IS_DELIMITER(c) ((c == delimiter) || (delim_whitespace && isblank(c)))

#define _TOKEN_CLEANUP() \
self->stream_len = slen; \
Expand Down Expand Up @@ -721,6 +719,9 @@ int tokenize_bytes(parser_t *self,
const char lineterminator = (self->lineterminator == '\0') ?
'\n' : self->lineterminator;

const int delim_whitespace = self->delim_whitespace;
const char delimiter = self->delimiter;

// 1000 is something that couldn't fit in "char"
// thus comparing a char to it would always be "false"
const int carriage_symbol = (self->lineterminator == '\0') ? '\r' : 1000;
Expand Down