Skip to content

Conversation

@rth
Copy link
Member

@rth rth commented Sep 26, 2019

The get_memview_* Cython helpers in KDTree and BallTree were used because at the time numpy/Cython didn't fully support memoryviews and now can be removed.

This was adapted from larsmans's refactoring PR in #4217

# flatten X, and save original shape information
np_Xarr = X.reshape((-1, self.data.shape[1]))
cdef DTYPE_t[:, ::1] Xarr = get_memview_DTYPE_2D(np_Xarr)
cdef const DTYPE_t[:, ::1] Xarr = np_Xarr
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Input array can be read-only, in which case setting it to a non const memoryview would fail.

@adrinjalali
Copy link
Member

Do we get some unintended speed degradation here? Could you maybe make sure there are no odd python interactions after the change?

@rth
Copy link
Member Author

rth commented Apr 7, 2020

Do we get some unintended speed degradation here? Could you maybe make sure there are no odd python interactions after the change?

I did benchmarks at the time, that showed no significant performance cost, but can't find them anymore. I'm waiting for official ASV benchmarks to be added #16723 so we have an official reference point.

Base automatically changed from master to main January 22, 2021 10:51
@jjerphan
Copy link
Member

@rth : are you still interested in pursuing this PR? 🙂

@rth
Copy link
Member Author

rth commented Apr 14, 2021

@jjerphan Feel free to continue it in a separate PR and ping me for review :) I think the only thing remaining was to resolve conflicts and run some benchmarks to confirm.

@jjerphan
Copy link
Member

Thanks for the quick reply!
I am following up a forest of PRs for neighbours.BinaryTrees and this one looks relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants