Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Replace numpy funcs for scalars. #5356

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
Oct 30, 2015
Merged

Replace numpy funcs for scalars. #5356

merged 1 commit into from
Oct 30, 2015

Conversation

Tillsten
Copy link
Contributor

This seems to be a minor speedup without any loss in code clarity.
For scalars value calling numpy functions is a lot slower than
using the math module.

In [12]: %timeit sin(radians(90))
The slowest run took 32.97 times longer than the fastest. This could mean that an intermediate result is being cached
10000000 loops, best of 3: 110 ns per loop

In [13]: %timeit np.sin(np.deg2rad(90))
The slowest run took 20.23 times longer than the fastest. This could mean that an intermediate result is being cached
1000000 loops, best of 3: 1.92 µs per loop

In [16]: %timeit np.round(1.1)
The slowest run took 4.98 times longer than the fastest. This could mean that an intermediate result is being cached
100000 loops, best of 3: 6.17 µs per loop

In [17]: %timeit round(1.1)
The slowest run took 12.39 times longer than the fastest. This could mean that an intermediate result is being cached
10000000 loops, best of 3: 121 ns per loop

@mdboom mdboom added this to the next bug fix release (2.0.1) milestone Oct 30, 2015
@mdboom
Copy link
Member

mdboom commented Oct 30, 2015

👍

@mdboom mdboom modified the milestones: Next bugfix release (1.5.1), next bug fix release (2.0.1) Oct 30, 2015
mdboom added a commit that referenced this pull request Oct 30, 2015
Replace numpy funcs for scalars.
@mdboom mdboom merged commit 980620e into matplotlib:master Oct 30, 2015
mdboom added a commit that referenced this pull request Oct 30, 2015
Replace numpy funcs for scalars.
@mdboom
Copy link
Member

mdboom commented Oct 30, 2015

Backported to v1.5.x as 5da9ed5

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