Hmm, this doesn't work for me. If I manually change DH.pm to use Math::BigInt lib => "GMP"; and then make the changes to my script as per your suggestion, my execution time drastically increases (from 5 to 25 seconds) until I revert the change to DH.pm.