-
-
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
Length of varargs not inferred from type signature #5383
Comments
Yes, I suppose we could inline the
As you can see, the code is lowered to the equivalent of indexing
But we do need to improve codegen of varargs functions; right now it can be quite bad. The length of the result of
Clearly the length of I think the code in the gist demonstrates the general problems we have with writing code to manipulate N-dimensional things, which has always been difficult. Maybe there is a way to write this in the form |
closed in favor of #5402 |
OK, thanks. Does that mean that when #5402 is fixed, doing something of the form Also, could you elaborate on that? I don't understand what you mean.
|
I've tried to find information about how varargs are supposed to be handled with regard to specialized compilation and inlining (e.g. #4374), but I still don't know much. IIUC, it seems that vararg functions are compiled for each type signature so that they are as efficient as manually writing several functions, which is why e.g.
sum()
was rewritten with only one varags definition here: #4751.If I'm correct, then it seems that the fact that the length of the varargs is not correctly inferred. This matters for me as it incurs a major performance penalty when indexing arrays with tuples of the same length as the varargs. See this discussion and the link to the gist: https://groups.google.com/d/topic/julia-users/o310JmWd7kg/discussion
Here's an illustration:
I would have thought that this would be
return 1
, sincetuplelen(x::(Int64,))
can obviously only be1
due to the type assertion.The text was updated successfully, but these errors were encountered: