I don't know the algorithm, but my point is that
c = a*b
will, for a BigInt, allocate memory. Because Numbers are immutable and BigInts
are Numbers, you can't write an algorithm mult!(c, a, b) that stores the
result in a pre-allocated "scratch space" c. Hence, you're doomed to
inefficiency compared to an implementation in C that uses such tricks. Don't get
me wrong, in the context of the overall Julia ecosystem our current design is
right one (immutability is a really awesome and important property), but there
are downsides.
But you don't have to live with the status quo. If you need efficient BigInt
calculations, perhaps a MutableBigInts.jl package would be in order. You could
define an OpaqueBigInt type (which would _not_ be a subtype of Number) and
implement mult!(c, a, b), add!(c, a, b), etc for that type. You could
basically copy the bigint implementation in base. gmp.jl is only 500 lines of
code and the changes might be very minimal, so you may be able to knock this
out in an afternoon :-). That is, unless making them not-numbers has too many
negative consequences. (You may find yourself creating additional methods of
other functions.)
Best,
--Tim