2012/2/25 Koichi Sasada <redmine / ruby-lang.org>:
> Feature #6083: Hide a Bignum definition
> https://bugs.ruby-lang.org/issues/6083
>
> Now, the struct RBignum which is a definition of Bignum in C is located in include/ruby/ruby.h.  It means we can't change implementation of Bignum.  For example, using GMP as Bignum representation.
>
> I propose to move the struct RBignum definition from include/ruby/ruby.h to bignum.c.  I believe no one use struct RBignum directly (except core).
>
> It has possibility to break binary compatibility.

I like this proposal.

However I think GMP or other multiprecision arithmetic library can be used
for slow operations such as multiplication and division
without hiding internal of struct RBignum.

The format conversion between RBignum and such library's implementation
should be O(n) (n is number of bits of the input numbers).
O(n) cost is negligible for operations slower than O(n), if input
numbers are big enough.

The conversion cost is not negligible for O(n) operations such as bitwise and.
But I doubt how such library is faster than Ruby for such operations.
-- 
Tanaka Akira
_______________________________________________
ruby-core mailing list
ruby-core / ruby-lang.org
http://lists.ruby-lang.org/cgi-bin/mailman/listinfo/ruby-core