-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
MAINT: Large overhead in some random functions #15511
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
Conversation
Do these fixes change the byte stream? |
I am not sure this is a regression, since I think the legacy version did not have the dtype kwarg normally? But we might as well backport probably. This should not change the byte streams, it should be purely maintenance in that sense. It might be nice to see if at least some of these are picked up by the benchmarks (if there are benchmarks drawing even a medium number from some of these distributions, I would expect so, however). |
slow calls to np.dtype.name replaced with np.dtype, mtrand.pyx and _generator.pyx updated, test test_warns_byteorder updated before: %timeit rs.random(): 520 ns ± 33.1 ns per loop %timeit rg.random(): 6.36 µs ± 222 ns per loop after: %timeit rs.random(): 453 ns ± 6.95 ns per loop %timeit rg.random(): 594 ns ± 9.66 ns per loop
d307b59
to
a15dc30
Compare
I tried to set up my laptop for consistent benchmark running (configuring the system so I could do
resulted in no significant changes. |
Likely means we don't have useful benchmarks. Here's a micro benchmark whoing a big improvement:
|
Fixes #15460. I can see a big improvement on a microbenchmark:
After this changeset (a15dc30)
|
@@ -312,13 +311,13 @@ cdef class Generator: | |||
|
|||
""" | |||
cdef double temp | |||
key = np.dtype(dtype).name | |||
if key == 'float64': | |||
_dtype = np.dtype(dtype) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would normally spell this
_dtype = np.dtype(dtype) | |
dtype = np.dtype(dtype) |
Does cython not like that?
(same throughout)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I change it, test are failing... seems that it is not proper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have a link to the CI failure?
Edit: caused diagnosed here: #15511 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need the original value so we can raise an error with it later. What about descr
or concrete_dtype
?
484ffce
to
df27b88
Compare
69f6edd
to
7d181f3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs still need updating as mentioned in https://github.com/numpy/numpy/pull/15511/files#r375407384
256a017
to
7821fcc
Compare
5c3c057
to
b0fa44a
Compare
b0fa44a
to
bf6ba07
Compare
bf6ba07
to
29fb22c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working through the doc fixes!
29fb22c
to
deb8571
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks @przemb |
Fixes #15460
_test_warns_byteorder_
updated