Skip to content

MAINT: Misc numeric cleanup - #11328

Merged
mhvk merged 6 commits into
numpy:masterfrom
eric-wieser:misc-numeric-cleanup
Jun 14, 2018
Merged

mhvk merged 6 commits into
numpy:masterfrom
eric-wieser:misc-numeric-cleanup

Conversation

@eric-wieser

@eric-wieser eric-wieser commented Jun 14, 2018 •

Copy link
Copy Markdown
Member

A bunch of small and somewhat orthogonal cleanups, all helping a little with #10151, and maybe #6103

Comment thread numpy/core/numeric.py
def extend_all(module):
adict = {}
for a in __all__:
adict[a] = 1

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.

Possibly written before set() was available...

@eric-wieser
eric-wieser force-pushed the misc-numeric-cleanup branch from f43dd98 to ebce412 Compare June 14, 2018 05:50
@eric-wieser
eric-wieser force-pushed the misc-numeric-cleanup branch from ebce412 to e2d83eb Compare June 14, 2018 05:54

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Even just the added comments are worth it! Looks good modulo a small nitpick.

# If two C types have the same size, then the earliest one in this list is used
# as the sized name.
_int_ctypes = ['long', 'longlong', 'int', 'short', 'byte']
_uint_ctypes = list('u' + t for t in _int_ctypes)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Total nitpick, but just ['u' + t for t in _int_ctypes] is faster (and clearer)

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.

A list comprehension would leak t into the module scope, unlike the above which does not.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah, had not thought about that - OK, would seem all good to go then!

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.

Although I think that is fixed in recent Python

@eric-wieser

Copy link
Copy Markdown
Member Author

Follow-up at #10151

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.

3 participants