Skip to content

BLD: use unsigned instead of signed for lengths, avoid build warnings #26759

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 7 commits into from
Jun 22, 2019

Conversation

jbrockmendel
Copy link
Member

I'm much more confident about the other two BLD PRs (#26757, #26758) than this, largely because:

  • in a couple of comments here I wrote that a certain term should always be non-negative. I haven't actually confirmed that this is always the case
  • This changed things from int64_t to uint64_t, but could also reasonably have changed them to size_t. I don't have a compelling reason for the correctness of the uint64_t choice.

@codecov
Copy link

codecov bot commented Jun 10, 2019

Codecov Report

Merging #26759 into master will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26759      +/-   ##
==========================================
- Coverage   91.71%    91.7%   -0.01%     
==========================================
  Files         178      178              
  Lines       50740    50740              
==========================================
- Hits        46538    46533       -5     
- Misses       4202     4207       +5
Flag Coverage Δ
#multiple 90.3% <ø> (ø) ⬆️
#single 41.21% <ø> (-0.11%) ⬇️
Impacted Files Coverage Δ
pandas/io/gbq.py 78.94% <0%> (-10.53%) ⬇️
pandas/core/frame.py 96.88% <0%> (-0.12%) ⬇️
pandas/util/testing.py 90.84% <0%> (-0.11%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0f3e8e8...ac9536d. Read the comment docs.

@codecov
Copy link

codecov bot commented Jun 10, 2019

Codecov Report

Merging #26759 into master will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26759      +/-   ##
==========================================
- Coverage   91.97%   91.97%   -0.01%     
==========================================
  Files         180      180              
  Lines       50756    50756              
==========================================
- Hits        46685    46682       -3     
- Misses       4071     4074       +3
Flag Coverage Δ
#multiple 90.56% <ø> (ø) ⬆️
#single 41.84% <ø> (-0.07%) ⬇️
Impacted Files Coverage Δ
pandas/io/gbq.py 88.88% <0%> (-11.12%) ⬇️
pandas/core/frame.py 96.89% <0%> (-0.12%) ⬇️
pandas/util/testing.py 90.94% <0%> (+0.1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b9b081d...fa66545. Read the comment docs.

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On board with the concept just question around casts (applicable in a few places)

@@ -471,7 +472,7 @@ static int end_line(parser_t *self) {
return 0;
}

if (!(self->lines <= (int64_t) self->header_end + 1) &&
if (!(self->lines <= (uint64_t) self->header_end + 1) &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this cast necessary?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I think it isn't.

@WillAyd WillAyd added the Clean label Jun 10, 2019
@@ -248,7 +248,8 @@ void parser_del(parser_t *self) {
}

static int make_stream_space(parser_t *self, size_t nbytes) {
int64_t i, cap, length;
uint64_t i, cap;
int64_t length;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does leaving this as is not introduce any new build warnings? Looks like assignments and comparisons are done with unsigned types within this function

@@ -651,7 +652,7 @@ static int parser_buffer_bytes(parser_t *self, size_t nbytes) {
stream = self->stream + self->stream_len; \
slen = self->stream_len; \
self->state = STATE; \
if (line_limit > 0 && self->lines == start_lines + (int64_t)line_limit) { \
if (line_limit > 0 && self->lines == start_lines + (uint64_t)line_limit) { \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to even have these casts? Fraught with peril to begin with using macros I think this just adds nuances / developer burden

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to remove these casts.

Should we consider getting rid of the macros? That's outside my region of competence.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea might be worth doing so in a separate PR. Here's the cpp take on macros:

https://isocpp.org/wiki/faq/inline-functions#inline-vs-macros

I could see this one being particular troublesome with our codebase:

https://isocpp.org/wiki/faq/misc-technical-issues#macros-with-if

I think the main downside to using inline vs macros would be support for pre-C99 compilers, but I don't think that's a problem given age and the fact that we have inline functions elsewhere in the code base

@WillAyd
Copy link
Member

WillAyd commented Jun 12, 2019

OK by me. Does this offer any performance improvements? Wondering if Cython optimizes for not doing a wraparound check like in this SO question:

https://stackoverflow.com/a/37933120/621736

@WillAyd WillAyd added this to the 0.25.0 milestone Jun 12, 2019
@@ -248,7 +248,8 @@ void parser_del(parser_t *self) {
}

static int make_stream_space(parser_t *self, size_t nbytes) {
int64_t i, cap, length;
uint64_t i, cap;
int64_t length;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is length signed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because there weren't any warnings telling us not to. Probably makes more sense unsigned liked the others.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you change this, otherwise lgtm.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing this requires changing a few other places to match. I think its benign, but not obvious. Go for it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep prob should

@jreback
Copy link
Contributor

jreback commented Jun 21, 2019

small comment, merge master and ping on green.

@jbrockmendel
Copy link
Member Author

Ping

@WillAyd WillAyd merged commit 2b9b58d into pandas-dev:master Jun 22, 2019
@WillAyd
Copy link
Member

WillAyd commented Jun 22, 2019

Thanks @jbrockmendel !

@jbrockmendel jbrockmendel deleted the tokenizer branch June 22, 2019 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants