-
-
Notifications
You must be signed in to change notification settings - Fork 0
Add same_value casting to np.astype #93
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
base: main
Are you sure you want to change the base?
Conversation
Choices for implementing the same_value cast:
2: Checking only the flag on the fast path
makes this timeit test go from 640ns to 880 ns:
Increasing the size to 10_000_000 and testing with/without the dummy flag makes the time go from 74.5ms to 69.5ms. The casting loops already use |
Update: it looks like the CPU can elide the
|
Sebastian says: you cannot change the values of the enums in https://github.com/mattip/numpy/blob/005ce7630792a94a9330b9af809904bb10ff2ea6/numpy/_core/include/numpy/ndarraytypes.h#L227C9-L227C30 |
This is something I have wanted for a while, to allow casting to a "smaller" dtype and raise an error or warning if there is overflow. For now this is a PR to my branch, so we can have a place to discuss the progress without adding too much noise to the general repo.