Subject: | Does not accept Math::BigInt objects as input |
It would be convenient if Math::GMPz accepted Math::BigInt objects in new(), ideally including overloads. Math::BigInt is a standard Perl method for big integers, so is quite common. Math::GMPz is *much* faster both in operations but also overhead, so is nice to use when doing lots of operations.
I suspect just stringifying the input is enough, so it works regardless of back end. But if you find a good non-brittle way to dig into the backend and optimize the Math::BigInt::GMP case, that would be awesome.
$ perl -E 'use Math::GMPz; use Math::BigInt; my $n = Math::BigInt->new(10); my $m = Math::GMPz->new($n); say "$n $m";'
Inappropriate argument supplied to new() at /Users/djacobsen/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/darwin-thread-multi-2level/Math/GMPz.pm line 197.
For comparison:
$ perl -E 'use Math::GMP; use Math::BigInt; my $n = Math::BigInt->new(10); my $m = Math::GMP->new($n); say "$n $m";'
10 10
$ perl -E 'use Math::Pari; use Math::BigInt; my $n = Math::BigInt->new(10); my $m = Math::Pari->new($n); say "$n $m";'
10 10
$ perl -E 'use Math::Int128 qw/int128/; use Math::BigInt; my $n = Math::BigInt->new(10); my $m = int128($n); say "$n $m";'
10 10