Home › Forums › kdb+ › embedPy: q list imported as numpy array › Re: embedPy: q list imported as numpy array
-
Hi Simon,
Please find some insight from our team as follows;
embedpy defaults to numpy arrays because that makes a lot more sense for the typical usage pattern.
numpy arrays behave enough like lists that this is usually not a problem.
In a rare case that it is, it’s reasonable to do explicit conversion by calling list(). it’s exposed to q as .p.list, so e.g. to pass a float vector to print() as a python list instead of a numpy array,
q).p.print .p.list 1 2 3f [1.0, 2.0, 3.0]
That’s exactly the same as doing that in python, but saves defining a function
q).p.eval["lambda x:print(list(x))";1 2 3f] [1.0, 2.0, 3.0]
Thanks for adding your question on the portal!
Kind regards,
David