Thanks for your answer.
Using comprehension actually slows down my code by 50%. Here is a microbenchmark that illustrates the slowdown.
julia> dict = open(readlines, "/usr/share/dict/american-english") ; map!(chomp,dict);
julia> gc() ; @time filter(str -> collect("cddeinostu") == sort(collect(str)), dict)
elapsed time: 1.095790328 seconds (72110504 bytes allocated)
julia> gc() ; @time filter(str -> [c for c in "cddeinostu"] == sort([d for d in str]), dict)
elapsed time: 1.512476691 seconds (86447632 bytes allocated)
By the way, I have often experimented the fact that adding type declaration for arrays actually slows down the code. Here is another example. The following code returns an array of all strings made of a letters R, b letters V and c letters B.
function path (a, b, c)
(a == 0 && b == 0 && c == 0) ? {""} :
[ a != 0 ? map(str->"R"*str, path(a-1, b, c)) : {},
b != 0 ? map(str->"V"*str, path(a, b-1, c)) : {},
c != 0 ? map(str->"B"*str, path(a, b, c-1)) : {} ]
end
julia> gc() ; @time length(path(5,5,5))
elapsed time: 7.532195402 seconds (1489954480 bytes allocated)
Now if I replace all {} by [] in the function definition, the timing is 6x slower (46.5s).
If I replace all {} by ASCIIString[], it is still slower (9.7s).
Using julia Version 0.2.0-prerelease+3893. "Commit d5dc226* 2013-10-01 on x86_64-linux-gnu (debian wheezy).