ketos icon indicating copy to clipboard operation
ketos copied to clipboard

Consider using an alternative to num for multiple precision arithmetic

Open vks opened this issue 10 years ago • 7 comments

num is one of the less efficient implementations of multi-precision arithmetic. (IIRC it is several orders of magnitude slower than GMP.) It might be worthwhile to use ramp (requires nightly and does not have fractions) or rust-gmp (bindings to C lib) instead.

vks avatar Feb 09 '16 11:02 vks

Performance was not my biggest concern, but I am open to replacing the num crate. However, I want to keep this project running on stable and open to users of the stable branch.

I've also considered that maybe a FixedNum(i64) variant of Value (which would transparently upgrade to arbitrary-precision when necessary) might also be a worthwhile performance enhancement. But I suppose that's true irrespective of which integer crate is used.

murarth avatar Feb 09 '16 17:02 murarth

@vks there is work on improving num crate. We want to split it into separate crates and leave num as "meta-crate" that will bring everything together for compatibility. So if you have some thoughts how to improve num feel free to PR :)

hauleth avatar Feb 15 '16 21:02 hauleth

@hauleth I think the split is a good idea. I wrote down my thoughts in https://github.com/rust-num/num/issues/102.

vks avatar Feb 16 '16 00:02 vks

@vks I know. I am one of the maintainers. Also I started work on that issue rust-num/num#164 to achieve that.

hauleth avatar Feb 16 '16 12:02 hauleth

@vks when was the last time you checked num's bigint performance? It has seen significant performance work more recently than rust-lang/num#102 was filed. I'm sure any library that uses asm will still be faster, but bigint is much better now.

cuviper avatar Feb 16 '16 18:02 cuviper

@cuviper It was at least a year ago. I'll dig up my use case, port it to num and evaluate the performance again. (I think it was calculating the discrete logarithm.)

vks avatar Feb 18 '16 00:02 vks

@cuviper Performance is much better now, it is only one order of magnitude slower than GMP. (I also had to implement a few algorithms that are not provided by num that might be suboptimal.)

See https://github.com/rust-num/num/issues/181.

vks avatar Mar 09 '16 22:03 vks