Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't clone Math::BigInt::GMP objects [rt.cpan.org #117161] #16

Open
atoomic opened this issue Oct 25, 2018 · 1 comment
Open

Can't clone Math::BigInt::GMP objects [rt.cpan.org #117161] #16

atoomic opened this issue Oct 25, 2018 · 1 comment
Labels

Comments

@atoomic
Copy link
Collaborator

atoomic commented Oct 25, 2018

Migrated from rt.cpan.org#117161 (status was 'new')

Requestors:

From srezic@cpan.org on 2016-08-23 13:16:25:

Math::BigInt::GMP objects cannot be cloned with Clone.pm:

$ perl5.18.4 -MMath::BigInt=only,GMP -MClone=clone -E 'say clone(Math::BigInt->new(42))->bstr'
failed to fetch mpz pointer at /opt/perl-5.18.4/lib/site_perl/5.18.4/Math/BigInt.pm line 3347.

Storable can deal with it:

$ perl5.18.4 -MMath::BigInt=only,GMP -MStorable=dclone -E 'say dclone(Math::BigInt->new(42))->bstr'
42

However, Storable cannot handle some types Clone can handle (most notably, Regexp).

A solution could be to invent a hook mechanism just as in Storable (STORABLE_freeze and STORABLE_thaw), or even better, re-use the Storable hooks if they are available.

A more simpler solution would be to just document this limitation, and point to other clone modules which may handle this (i.e. Storable).

In this special situation it would be possible to fallback to the pure perl Math::BigInt implementation (using "use Math::BigInt only => 'Calc'"), but this would be a huge performance hit when doing real calculations.
@atoomic
Copy link
Collaborator Author

atoomic commented Oct 25, 2018

confirmed this is still an issue with perl 5.28.0

> perl.528.0 -MMath::BigInt=only,GMP -MClone=clone -E 'say clone(Math::BigInt->new(42))->bstr'
failed to fetch mpz pointer at /usr/local/cpanel/3rdparty/perl/528/lib/perl5/cpanel_lib/Math/BigInt.pm line 3527.

@atoomic atoomic added the bug label Oct 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant