Repository navigation
ENH: Increase np.atleast_2d and np.atleast_3d performance - #30880
benediktjohannes wants to merge 6 commits into
Conversation
Credits to: @eendebakpt Contributed by Benedikt Johannes
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
I've got the results for the benchmark! 👍 Script: (Credits to @eendebakpt for the great script👍) Results: Old ( New ( |
|
Test failure is unrealted (can't install build environment) |
|
Should I write release notes 2.5 for this change, @ngoldbaum? Or is this done by the team? I only know this from CPython. |
|
Because it says:
And the change is kind of user facing in my opinion because the performance is changed and users might notice this (and the latest news document also includes performance improvements). |
|
minor performance improvements like this don't need a release note |
|
All checks pass, do I need to use any command like /merge? |
|
So without the unrelated one |
|
Please be patient, I added the milestone so this won't get lost before the next major release this summer. |
|
Thank you! |
|
But one question: Is everything finished that I got to do? So can I just wait for the summer without doing anything for this? |
|
Maybe sooner, this PR has only been open for a day or so. The project doesn't move terribly quickly and people do code review as their time and interest permits. I was also planning to look closer at this at some point. Usually we like to leave PRs that make performance improvements and add new features open for at least a few days. |
|
Also, IMO this PR shouldn't be backported, so in practice very few people will be able to use this until NumPy 2.5 comes out this summer. |
|
Ah, okay, thank you very much for the Information! Don’t feel stressed about it! |
| if result.ndim == 0: | ||
| result = result.reshape(1, 1) | ||
| elif result.ndim == 1: | ||
| result = result[_nx.newaxis, :] |
There was a problem hiding this comment.
This could be np.reshape(-1, 1) i think. It is quite a bit faster.
There was a problem hiding this comment.
Thanks for the idea! Does this apply to 2d and 3d as well?
There was a problem hiding this comment.
Not sure, but you could try
|
It's been seven months so it might make sense to make a new PR if the OP has gone on to other projects. |
|
@ngoldbaum @eendebakpt I‘m still here 🙂👍 I always wanted to get this done and merged, it’s just that I didn’t Post anything here anymore because You Said I should not be so pushy, so no Problem, we can add this Suggestion by @eendebakpt, thank you by the way for the good idea |
|
@eendebakpt thanks for the Like, but I think you didn’t See the comment above concerning my question to your Suggestion |
|
@eendebakpt which axis should be -1 in 3d then? I‘m sorry, Im Not quite sure about your Suggestion, so Could you maybe do This Addition in a seperate PR then and get this merged at First because its a Bit offtopic or could you maybe explain a Bit why this change is correct in 2d and in what Form it could be correct for 3d? Thanks! |
Lets keep the changes out for this PR (I did not check the 3d case, maybe that is not so easy as the 2d case) |
|
Perfect, thanks, then ready for merge |
|
@ngoldbaum this PR is Open since 7 months, do you think that it’s maybe possible to get this merged soon, please? |
|
And ready for Review |
|
I'm on vacation this week. If you'd like to get maintainer attention, I invite you to come to one of our weekly video calls |
|
Oh, sorry @ngoldbaum, didnt want to interrupt you! Thanks for the Information and have a Nice vacation! |
This pull request features #26130 by @eendebakpt (credits to him for the great work 👍 ) and should improve the performance of
np.atleast_2dandnp.atleast_3d.I've not tested the changes, but it seems quite obvious to me from looking at the code that these should be (at least in most cases) positive (and in general more positive than negative, but I'm not one hundred percent sure, so please correct me if I'm mistaken, thanks).
Credits to: @eendebakpt
Contributed by Benedikt Johannes