PERF Only call malloc twice in liblinear to_sparse helpers#14170
PERF Only call malloc twice in liblinear to_sparse helpers#14170jeremiedbb merged 1 commit intoscikit-learn:masterfrom alexhenrie:prealloc
Conversation
|
I think the code is fine in this instance, but the explanation is helpful
for the reviewer
|
|
@rth Could you merge this please? Feel free to run your own benchmarks. |
|
Thanks @alexhenrie , I'm just not too confident in my ability to review C code. Maybe @jeremiedbb or @pierreglaser would be interested in doing a second review? |
|
We looked at it with pierre and it seems fine. There's one thing not related to this PR still. When the malloc fails, the error is not handled anywhere after in liblinear.pyx (unlike for libswm which handles the error in libsvm.pyx). We should handle it when calling set_problem in liblinear also. |
|
Thanks @jeremiedbb , feel free to merge then ) |
|
@jeremiedbb Thanks for reviewing this! In his comment above, @jnothman said that he just wanted to know what the reason was and he did not think a comment is necessary in the code. If you want a C comment explaining |
|
it's fine. It's not like we modify this code very often :) Thanks @alexhenrie ! |
|
Thank you! |
By my benchmarks, this way takes 1% less time and 1% less memory. Plus, it makes error handling a lot easier.