Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Draft: ENH: sparse: rewrite get_thunk to support creation of csr_array struct#25117

Draft
dschult wants to merge 3 commits into
scipy:mainfrom
dschult:csr_struct_get_thunk
Draft

Draft: ENH: sparse: rewrite get_thunk to support creation of csr_array struct#25117
dschult wants to merge 3 commits into
scipy:mainfrom
dschult:csr_struct_get_thunk

Conversation

@dschult
Copy link
Copy Markdown
Contributor

@dschult dschult commented May 10, 2026

This PR shows how the sparsetools core function get_thunk can take CSR/CSC input directly to the a csr_array struct rather than having the inner functions create/package the struct. The sparsetools spec is given a new symbol 'C' in addition to ilITBVW. Previously many functions used iiIIT to denote the 5 input args to describe each CS input. Some function have 2 input arrays and 1 output array so they end up with 15 args!! This PR change could cut that to 3. The resulting code is arguably nicer too -- certainly the function signatures are.

This proof of concept rewrites get_thunk in the first commit and then in 2nd commit it implements the csr_todense function using the sparsetools spec 'C*T' instead of 'iiIIT*T'.

I'm putting this up as a draft PR for feedback. There is still a bunch of work to be done including runtime benchmarks, RAM needs, compile time, size of .so files, etc.

cc: @perimosocordiae @stefanv

@dschult dschult added enhancement A new feature or improvement scipy.sparse C/C++ Items related to the internal C/C++ code base labels May 10, 2026
dschult added 2 commits May 13, 2026 11:09
but no functions that use 'C' yet. Make sure tests pass.
shift max_array_size to 1st pass. simplify typenum processing
make 2nd pass use switch like 1st pass
@dschult dschult force-pushed the csr_struct_get_thunk branch from 70e92b9 to 74e6c5f Compare May 13, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C/C++ Items related to the internal C/C++ code base enhancement A new feature or improvement scipy.sparse

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant