8000 MAINT: Cleaned up mintypecode for Py3 by madphysicist · Pull Request #14967 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

MAINT: Cleaned up mintypecode for Py3 #14967

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 1 commit into from
Nov 23, 2019

Conversation

madphysicist
Copy link
Contributor

This is a small cleanup PR for mintypecode.

  • Using generators instead of full-blown lists
  • Using set for search instead of list
  • Using min to get single element instead of sorting full list

All changes are internal, and should be relatively uncontroversial. As such no tests were modified in this PR.

@seberg
Copy link
Member
seberg commented Nov 23, 2019

Thanks, looks good at first sight. Could you remove the release note again? I think it is unnecessary here.

@madphysicist
Copy link
Contributor Author

@seberg Done

Using generators instead of full-blown lists
Using set for search instead of list
Using min to get single element insteaf of sorting full list
@seberg seberg merged commit 2fb8540 into numpy:master Nov 23, 2019
@madphysicist madphysicist deleted the mintypecode-cleanup branch November 24, 2019 02:35
@madphysicist
Copy link
Contributor Author

@SebetG. Thanks. Any thoughts on #14966?

l = [(_typecodes_by_elsize.index(t), t) for t in intersection]
l.sort()
return l[0][1]
return min((_typecodes_by_elsize.index(t), t) for t in intersection)[1]
Copy link
Member

Choose a reason for hiding this comment

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

Better as:
return min(intersection, key=_typecodes_by_elsize.index)

@madphysicist madphysicist restored the mintypecode-cleanup branch November 24, 2019 14:33
@madphysicist
Copy link
Contributor Author

@eric-wieser well seen. I've updated the branch. @seberg I don't know how it works when I change the branch after a merge.

madphysicist added a commit to madphysicist/numpy that referenced this pull request Nov 24, 2019
@seberg
Copy link
Member
seberg commented Nov 24, 2019

You would have to create a new PR for followups.

@eric-wieser
Copy link
Member

You can create a new PR from the same branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0