The basic object for numpy operations is the ndarray which has the tolist() function. The function converts the array (whatever its shape) into a list representation of basic Python types, which in turn converts just fine in Janus. So something like this works practically:
example2 :-
X = [[1,2,3], [3,5,3], [0,2,1]],
raw(numpy:transpose(X), XT),
raw(numpy:matmul(XT, X),Square),
cmd(numpy:ndarray:tolist(Square),Out), % <-- Convert as a last step.
writeln(Out).
In this case at least, I don’t think that it is a problem, it just makes the py_object(true) more useful behaviour.
I personally think that py_object(true) is a better default. Say X has type T, when you convert X from Python to Prolog to Python, it may not have type T, and it may not be possible to pass it to other functions. That sort of thing is likely to happen with libraries like SpaCy, pytorch, tensorflow, and so on, which use complex types. I guess its going to happen whenever the response is a class … It happens in numpy too since an ndarray is iterable and will end up converted to a list… but then if you want to pass it to some function which expects to be able to run X.shape on its argument (ndarray has it, lists do not), the code will fail.