X Tutup
Skip to content

Replace numpy funcs for scalars.#5356

Merged
mdboom merged 1 commit intomatplotlib:masterfrom
Tillsten:ticker_maint
Oct 30, 2015
Merged

Replace numpy funcs for scalars.#5356
mdboom merged 1 commit intomatplotlib:masterfrom
Tillsten:ticker_maint

Conversation

@Tillsten
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

X Tutup