python-flint
python-flint copied to clipboard
fmpz.__init__ could use base 0 to autodetect string type
Although it's not well-documented, fmpz_set_str supports base 0 to auto-detect based on prefix (it falls through to GMP):
fmpz_t y;
fmpz_init(y);
fmpz_set_str(y, "0x64", 0);
fmpz_print(y);
printf("\n");
fmpz_clear(y);
return 0;
100
https://github.com/flintlib/python-flint/blob/main/src/flint/types/fmpz.pyx#L84
It should be like these:
In [17]: int("0xf", 0)
Out[17]: 15
In [18]: gmpy2.mpz("0xf", 0)
Out[18]: mpz(15)
Feel free to open a pull request: https://python-flint.readthedocs.io/en/latest/workflow.html