-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
CLN: Added static types #33126
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
CLN: Added static types #33126
Conversation
pandas/_libs/parsers.pyx
Outdated
@@ -591,6 +579,9 @@ cdef class TextReader: | |||
self.parser.quotechar = ord(quote_char) | |||
|
|||
cdef _make_skiprow_set(self): | |||
cdef: | |||
int64_t i | |||
|
|||
if isinstance(self.skiprows, (int, np.integer)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
util.is_integer
pandas/_libs/parsers.pyx
Outdated
@@ -591,6 +579,9 @@ cdef class TextReader: | |||
self.parser.quotechar = ord(quote_char) | |||
|
|||
cdef _make_skiprow_set(self): | |||
cdef: | |||
int64_t i |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For anything that is used to index Python objects you should opt for Py_ssize_t
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, my reason to have this as int64_t
is because below we have the line:
for i in self.skiprows:
parser_add_skiprow(self.parser, i)
Which calls parser_add_skiprow
, parser_add_skiprow
is defined here:
pandas/pandas/_libs/parsers.pyx
Line 207 in 7673357
int parser_add_skiprow(parser_t *self, int64_t row) |
and i
is in the place of row
, I tried to match the type, to avoid (potential) casting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that should also be a Py_ssize_t; I don't know what effort it would require to update that but OK to split off on a separate PR too
LGTM |
@jreback here as well; I think good to merge |
thanks @MomIsBestFriend |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff