Skip to content
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

array_scalar * numpy_scalar is slow. #5030

Open
charris opened this issue Sep 2, 2014 · 3 comments
Open

array_scalar * numpy_scalar is slow. #5030

charris opened this issue Sep 2, 2014 · 3 comments

Comments

@charris
Copy link
Member

charris commented Sep 2, 2014

Some timings:

In [8]: a = np.float64(123)

In [9]: b = np.array(4.)

In [10]: timeit a*b
10000000 loops, best of 3: 110 ns per loop

In [11]: timeit b*a
1000000 loops, best of 3: 985 ns per loop

In [12]: timeit a*a
10000000 loops, best of 3: 66.6 ns per loop

In [13]: timeit b*b
1000000 loops, best of 3: 349 ns per loop

In [14]: timeit a + b
10000000 loops, best of 3: 109 ns per loop

In [15]: timeit b + a
1000000 loops, best of 3: 1.01 µs per loop

Maybe a fastpath it needed.

@juliantaylor
Copy link
Contributor

rmul

@charris
Copy link
Member Author

charris commented Sep 2, 2014

Cool! Or maybe, hot stuff ;) I love those graphs but I'm still coming to grips with how to understand them.

@juliantaylor
Copy link
Contributor

it shows the sampled callstack with the width being the cumulative runtime. The main bottlenecks are ufunc_hasattr and GetPriority which have an array fastpath but no scalar one. Next largest fraction are a bunch of subtype check from PyArray_DescrFromScalar

juliantaylor added a commit to juliantaylor/numpy that referenced this issue Sep 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants