JuliaLang/julia — pull request #4136 by kmsquire (2013-08-23 22:20:44+00:00)
Title: Speed up partitions(n), partitions(n,m) iteration

* Reuse output array
* Specialize `IntegerPartitions`, `FixedPartitions` based on whether or not to copy
* Specialize `collect()` to always copy
* Reduce memory allocation

The speed of `collect()` hasn't changed much, and iterating with `for` is about 4x as fast as using `collect()`

I was wondering if I could specialize types using `Bools` directly (you can't), so I'm specializing using

```julia
partitions(n::Int; copy::Bool=false) = IntegerPartitions{int(copy)}(n)
```