test_misc.txt
1 Miscellaneous Functions 2 ----------------------- 3 4 >>> import gmpy2 5 >>> from gmpy2 import mpz 6 >>> gmpy2.version() 7 '2.1.0b6' 8 >>> gmpy2.mp_limbsize() in (32,64) 9 True 10 >>> gmpy2.mp_version().split()[0] in ['GMP', 'MPIR'] 11 True 12 >>> check_gmp = gmpy2.mp_version().startswith('GMP') and '5.0.0' <= gmpy2.mp_version().split()[1] 13 >>> check_mpir = gmpy2.mp_version().startswith('MPIR') and '3.0.0' <= gmpy2.mp_version().split()[1] 14 >>> check_gmp or check_mpir 15 True 16 >>> gmpy2.mpfr_version() and gmpy2.mpfr_version().startswith('MPFR') 17 True 18 >>> gmpy2.mpfr_version() and '3.1.0' <= gmpy2.mpfr_version().split()[1] 19 True 20 >>> gmpy2.mpc_version() and gmpy2.mpc_version().startswith('MPC') 21 True 22 >>> gmpy2.mpc_version() and '1.0' <= gmpy2.mpc_version().split()[1] 23 True 24 >>> gmpy2.license() 25 'The GMPY2 source code is licensed under LGPL 3 or later. The supported versions of the GMP/MPIR, MPFR, and MPC libraries are also licensed under LGPL 3 or later.' 26 27 >>> gmpy2.get_cache() 28 (100, 128) 29 >>> gmpy2.divm(5,7,13) 30 mpz(10) 31 >>> gmpy2.set_cache(0,16) 32 >>> gmpy2.get_cache() 33 (0, 16) 34 >>> for i in range(1000): a=mpz(i) 35 >>> del(a) 36 >>> gmpy2.set_cache(100,128) 37 >>> gmpy2.get_cache() 38 (100, 128) 39 >>> gmpy2.set_cache('a', 128) 40 Traceback (most recent call last): 41 File "<stdin>", line 1, in <module> 42 TypeError: ** message detail varies ** 43 >>> gmpy2.set_cache(-10, 128) 44 Traceback (most recent call last): 45 File "<stdin>", line 1, in <module> 46 ValueError: ** message detail varies ** 47 >>> gmpy2.set_cache(10000, 128) 48 Traceback (most recent call last): 49 File "<stdin>", line 1, in <module> 50 ValueError: ** message detail varies ** 51 >>> gmpy2.set_cache(100, -1) 52 Traceback (most recent call last): 53 File "<stdin>", line 1, in <module> 54 ValueError: ** message detail varies ** 55 >>> gmpy2.set_cache(100, 100000) 56 Traceback (most recent call last): 57 File "<stdin>", line 1, in <module> 58 ValueError: ** message detail varies ** 59 >>> 1 60 1 61