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

convenient julia->python conversion of structured data

Open amilsted opened this issue 2 years ago • 2 comments

Hello! Thanks for PythonCall/juliacall :)

Currently, passing e.g. {"s": 2, "t": 3} to Julia will result in a PyDict{Py, Py}. It would be great to have a way to convert such structured data with "simple" python elements into native types (in this case Dict{String, Int}).

The pyconvertnative() idea from #172 seems like it could handle this case?

amilsted avatar Jul 14 '22 17:07 amilsted

Indeed, there is no such thing implemented, but I'd happily take a PR for it.

cjdoris avatar Jul 19 '22 18:07 cjdoris

My current hack is to do python->JSON->julia, which handles the "nested dict of simple types" case pretty well, but is clearly not optimal :)

amilsted avatar Jul 19 '22 20:07 amilsted