# Python mpfr floats to Julia BigFloat / mpfr

**URL:** <https://discourse.julialang.org/t/python-mpfr-floats-to-julia-bigfloat-mpfr/119724>\
**Category:** Specific Domains\
**Tags:** question\
**Created:** [September 23, 2024, 3:22am UTC](https://discourse.julialang.org/t/python-mpfr-floats-to-julia-bigfloat-mpfr/119724 "2024-09-23T03:22:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![thedeyan](https://avatars.discourse-cdn.com/v4/letter/t/6bbea6/32.png) [@thedeyan](https://discourse.julialang.org/u/thedeyan)\
**Post date:** [September 23, 2024, 3:22am UTC](https://discourse.julialang.org/t/python-mpfr-floats-to-julia-bigfloat-mpfr/119724/1 "2024-09-23T03:22:05Z")

</div>

I have a numpy array of type object and filled with `gmpy2.mpfr` numbers:

```julia
x = np.empty(3, dtype=object)
x[0] = mpfr("0.4", 1000)
x[1] = mpfr("0.6", 1000)
x[2] = mpfr("0.8", 1000)

```

and I have a function in Julia which operates on `BigFloat` array:

```julia
function compfunc(A):
...
end

```

which I import in python via:

```julia
from julia import Main
Main.include("myfile.jl")
Main.compfunc(x)

```

however I get an error

```julia
RuntimeError Traceback (most recent call last)
Cell In[16], line 1
----> 1 Main.compfunc(x)

RuntimeError: <PyCall.jlwrap (in a Julia function called from Python)
JULIA: MethodError: no method matching zero(::PyObject)

```

What can I do to run this?

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [September 23, 2024, 7:06am UTC](https://discourse.julialang.org/t/python-mpfr-floats-to-julia-bigfloat-mpfr/119724/2 "2024-09-23T07:06:39Z")

</div>

Looks like a type conversion issue. The language interface packages do not have general ways to convert between arbitrary types among several languages. Each combination must be implemented specifically, and these packages will implement types in the base languages and maybe a standard like NumPy, not arbitrary third-party libraries. JuliaCall/PythonCall allows you to extend its Julia-to-Python type conversion, no idea if PyJulia allows that in either direction. It’s possible to extract `gmpy2.mpfr`’s data (likely in C) and instantiate a `BigFloat` on the Julia side, but that’s a lot of work to be done, possibly in all libraries and languages involved because `gmpy2` and Julia don’t seem to wrap MPFR the same way (instance-wise vs global precision).
