JuliaStats/DataFrames.jl — pull request #667 by simonster (2014-08-07 21:16:20+00:00)
Title: Speed up writetable

This generates specialized code for `printtable` every set of column types, which speeds up the test case:

```julia
make_testdf(n) = DataFrames.DataFrame(a=rand(1:typemax(Int), n), b=rand(1:typemax(Int), n), c=rand(1:typemax(Int), n), d=rand(1:typemax(Int), n), e=[randstring(10) for i = 1:n], f=[randstring(100) for i = 1:n], g=float64(rand(1:100, n)), h=[randstring(10) for i = 1:n], i=[randstring(10) for i = 1:n]);
df = make_testdf(2000000);
@time DataFrames.writetable("test.csv", df)
```

by about 25% on my system. I don't know if this is a good idea in general since it also means we have to compile specialized code for every size of DataFrame, but for DataFrames with many rows it's definitely advantageous. Writing the integer columns is the most expensive part, and without them there is now almost no allocation. (The allocation comes from `show(io, ::Int)`.) The second most expensive part is writing the strings in `print_escaped` from Base.

Ref JuliaLang/julia#7893