Skip to content

MAINT: Push down declarations in _convert_from_* - #15288

Merged
seberg merged 4 commits into
numpy:masterfrom
eric-wieser:tidy-dtype-move-declarations
Jan 8, 2020
Merged

seberg merged 4 commits into
numpy:masterfrom
eric-wieser:tidy-dtype-move-declarations

Conversation

@eric-wieser

Copy link
Copy Markdown
Member

No description provided.

This makes it easier to reason about which variables contain mutable state.
C99 makes some of this possible, while other parts were already possible.
This makes it easier to reason about which variables contain mutable state.
C99 makes some of this possible, while other parts were already possible.
This makes it easier to reason about which variables contain mutable state.
C99 makes some of this possible, while other parts were already possible.
Note that in order to not reference a declaration after `goto`ing past it, one DECREF moved out of `fail` and inline.

@seberg seberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Clear enough some small comment. Only real issue is the fail labels doing XDECREF on some of these, so they need to be NULL initialized, and thus remain at the top.

Comment thread numpy/core/src/multiarray/descriptor.c
goto fail;
}
offset = PyArray_PyIntAsInt(off);
long offset = PyArray_PyIntAsInt(off);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
long offset = PyArray_PyIntAsInt(off);
int offset = PyArray_PyIntAsInt(off);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Would rather not fix that type of thing in this patch - offset was declared long before I moved the declaration, so I'd like this commit to not change its type.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fine, I had missed that it was long, because I remembered that the top of the function everything was int.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

... which is exactly the type of mistake I'm trying to avoid making myself by moving the types down to where they're used :)

Comment thread numpy/core/src/multiarray/descriptor.c
@seberg

seberg commented Jan 8, 2020

Copy link
Copy Markdown
Member

OK, sorry for the noise. Let me put this in as is then and leave that weird long for later :).

@seberg
seberg merged commit 3b7aac3 into numpy:master Jan 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants