PythonCall.jl icon indicating copy to clipboard operation
PythonCall.jl copied to clipboard

add pyconvert(x)

Open CarloLucibello opened this issue 2 years ago • 6 comments

For convenience, it would be nice to expose

pyconvert(x) = pyconvert(Any, x)

CarloLucibello avatar May 14 '22 09:05 CarloLucibello

Perhaps, but you generally shouldn't be using pyconvert(Any, x), you should use a more specific type. The only good reasons I can see for pyconvert(Any, x) are:

  • Interactive use, where you already know the conversion will do what you want.
  • Generic programming, where you don't actually know anything about x.

cjdoris avatar May 21 '22 20:05 cjdoris

Those 2 usage examples seem pretty common. Moreover, I would find it very useful to have a pyconvert(Any, x) with a recursive behavior, something like what I poorly implemented https://github.com/CarloLucibello/HuggingFaceDatasets.jl

CarloLucibello avatar May 28 '22 07:05 CarloLucibello

I've previously had discussions about adding a function pyconvertnative(x) which converts x (recursively) to a 'native' Julia object if possible (list to Vector, dict to Dict etc.).

cjdoris avatar May 28 '22 15:05 cjdoris

I just added my two cents to the pyconvertnative() discussion, see #128

Maybe we could continue the discussion here?

hhaensel avatar Oct 30 '22 19:10 hhaensel

This issue has been marked as stale because it has been open for 30 days with no activity. If the issue is still relevant then please leave a comment, or else it will be closed in 7 days.

github-actions[bot] avatar Sep 10 '23 01:09 github-actions[bot]

This issue has been closed because it has been stale for 7 days. If it is still relevant, please re-open it.

github-actions[bot] avatar Sep 18 '23 01:09 github-actions[bot]