-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Refinements to hvncat
#41143
Refinements to hvncat
#41143
Conversation
1-dimensional caseIn this discussion the idea came up that in the 1-dimensional case
Is this intended? Let me also remark that the shape form of MethodsIt seems to me that the code contains quite a few redundant methods. Is this intentional? In my opinion, this makes the code hard to read. Some examples: Here the second line covers all the following ones (without runtime overhead, I believe):
Here the second line covers the first:
|
Yes, it is intended. That could potentially be changed... I'd have to dive back into the parser code though to make that work. With respect to type stability, is it any less type-stable than e.g.
I'm not sure why all the different
Ah, yes, good catch. Before the first one dispatched to |
I was only giving examples of what seemed redundant methods to me. There are more, for instance:
I think it would be good to take the time and check all methods introduced for |
Julia made me do those to resolve ambiguity. That's where most of this apparent redundancy is coming from. |
From @mbauman 's comment here: #41101 (review)
Normal dispatch should ensure it isn't empty. But, the new checks in this PR ensures: 1) elements of |
I see, some method definitions in the source code are more subtle than I thought. Regarding the multiple methods for Something else: One still gets
As I explained here, I think |
I understand, and there's a sense to it. But the base output for all the cat methods are empty vectors. I raised a related issue with respect to the other methods here: #40111
I don't have a strong opinion on what's right here, but I don't want to break that pattern unless there's consensus about it. |
I see. However, wouldn't that mean that However, after the latest commit 88694a0 it leads to a different error, even for non-empty
EDIT: The first example also shows that one cannot really compare |
Haha. Now you see my struggle. I removed the ::Number... method and thought it seemed to be working. I'll have to add it back again. |
I'll give some more thought to your view on the bare-minimum call, @matthias314. |
Co-authored-by: Jameson Nash <[email protected]>
71948df
to
c171978
Compare
I was able to tighten up the 0-length dimension issue. A couple wrong inputs do produce an output, but it's not too bad. I'm having trouble figuring out how to detect that case. e.g. |
Just as a general tip: Reviewing PRs is a lot easier if you open smaller separate PRs, which each only address one issue at a time instead of large PRs addressing multiple separate issues. I know that putting everything into one PR is often easier as an author, because you don't need to think about dependencies and possible conflicts, but as a reviewer, I am often not as familiar with all details of the implementation as you are, so it's quite difficult to know where to start reviewing. It's not immediately obvious here, which changes are actually bug fixes, which are performance improvements and which are new features. If those were separate parts, I am sure you would get much quicker reviews because it is clear what the change does and what issue it fixes. Please don't let this discourage you in any way though, your work here is very much appreciated! I just thought this might be generally helpful advice for contributing to OSS projects. I will still try to get around reviewing this soon. |
@simeonschaub, sure, I understand. I can break some of this up into smaller bits. |
Can this be closed in favor of the new series of PRs? |
This PR is collecting changes based on feedback on the functions, including #41111, #41107, and #41047.
@inbounds
and@inline
hints. Hopefully someone can ensure they're proper this time 😅const a = fill(1); const b = [a a]; [a a ;;; b]
) improved to ~2x faster and 10 allocations 784, compared withcat([a a], b, dims = 3)
's 32 allocations and 1.12 KiB.