Hello, I am using wolframclient
for a project, and I have gotten the hang of it. However, I want to use it for arbitrary precision arithmetic, which means passing arbitrary precision numbers between python and the Mathematica kernel and back. Is there a way to do this. Some stuff I have tried already:
with WolframLanguageSession() as session:
x = session.evaluate(wl.ToString(wl.N(1/3, 100)))
print(x)
which gives 0.333333
I have also tried passing the numbers to a function from an external .m package, without success:
with WolframLanguageSession() as session:
session.evaluate(wl.SetDirectory("mathematica_files"))
session.evaluate(wl.Needs('MyPackage`'))
session.evaluate(wl.ResetDirectory())
a = wl.N(33/100, 100)
b = wl.N(24/100, 100)
res = session.evaluate(
wl.MyPackage.MyFunction(a,b)
)
print(res)
which again gives a less-than-machine-prec number.
Is there any way to serialize some python library type which would allow me to make use of high-precision arithmetic in Mathematica?