Skip to content
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

accept more Integer types for dims::Int... arguments #7956

Closed
wants to merge 1 commit into from

Conversation

stevengj
Copy link
Member

As discussed on the mailing list, there's no real reason that functions like rand(dims::Int...) can't accept other Integer types. This patch genericizes a number of functions in Base that took Int... arguments to accept Integer....

There shouldn't be a performance penalty, since I made sure convert(Dims, dims::Dims) returns dims by adding a new diagonal tuple method to convert.

Functions accepting an explicit (Int...) (== Dims) tuple still require Int; it was too much of a pain to change these, and they are generally lower-level functions than the varargs functions.

@JeffBezanson
Copy link
Sponsor Member

There is somewhat of a reason, though I don't know how convincing: these signatures permit O(n^m) specializations. This can lead to excessive compilation and compile time. And at a certain point, julia will stop specializing, so you might get much worse performance for (Int64,Int64,Int64,Int32) than for (Int32,Int64). You are better off converting things to Int at the call site.

@quinnj
Copy link
Member

quinnj commented Aug 19, 2014

#7709 was recently fixed that dealt with this same issue. I think it may be good to just allow Integer.... Ideally we'd be able to follow the pattern of allowing more general types at the UI/exported level, and take specific types for internals, but I'm not sure how relevant that with some of the definitions here.

@quinnj
Copy link
Member

quinnj commented May 9, 2016

It seems we already have rand(dims::Integer...) at random.jl:209; are the other changes here still relevant/needed?

@stevengj
Copy link
Member Author

stevengj commented May 9, 2016

There are also similar, reshape, getindex, and many other functions. But there doesn't seem to have been an recurring need for these, so maybe it's better to just close this for now and re-visit if the issue resurfaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants