Why `Any` in `Any[func1, func2, func3, func4]`?

#1

I’m reading the “Performance Tips” section of the official documentation. At the bottom of that section there’s a piece of code that baffles me a little:

julia> x = randn(10000);

julia> fmt(f) = println(rpad(string(f)*": ", 14, ' '), @elapsed f(x))

julia> map(fmt, Any[copy_cols, copy_rows, copy_col_row, copy_row_col]);
copy_cols:    0.331706323
copy_rows:    1.799009911
copy_col_row: 0.415630047
copy_row_col: 1.721531501

Is there any reason behind that Any?

0 Likes

#2

Any[] used to be written as {}. This was changed in https://github.com/JuliaLang/julia/commit/f96e33b1fded4d9671b7ca5fa71e236785257ca6 (4 years ago) and the codebase was probably regex search and replaced. You are right that it is not needed now. Feel free to open a PR to remove it.

3 Likes