EmbedPy integration
KX Platform offers direct integration with embedPy through a Platform asset package. It offers the full functionality available of the KX Fusion interface detailed at code.kx.com
Currently all Linux flavours supported by the Platform support embedPy integration; including Ubuntu 16/18 and Red Hat 6/7. The KX Platform embedPy package is also available for Windows.
The only requirement is the ability to update the $QHOME
with the necessary libraries and Kdb+ script wrapper as part of the KX Platform installation.
Platform embedPy asset installation
The EmbedPy Platform asset is installed in the same way as all Platform, Platform asset and Solution packages are installed. Place the package in the relevant package directory and run through the installation script. Further details on Platform and package deployment can be retrieved via the Deployment guides
EmbedPy KX Analyst integration
EmbedPy is fully integrated with the KX Analyst component of the KX Platform.
Python simple code execution
The EmbedPy integration allows execution of Python code within the KX Analyst IDE or from a script. In both the IDE and scripts prefix Python code with p)
Q scripts can load and execute multiline Python code. Prefix the first line of the code with p)
and indent subsequent lines of Python code according to the usual Python indentation rules.
$ cat embedPytest.q
a:1 / q code
p)def add1(arg1): # Python code
return arg1+1 # still Python code
Full scripts of Python code can be executed in q, using the .p
file extension. The script is loaded as usual.
Converting Python data to q
Given obj
, an embedPy object representing Python data, we can get the underlying data as foreign or q.
e.g.
q)x:.p.eval"(1,2,3)"
q)x
{[f;x]embedPy[f;x]}[foreign]enlist
q)x`.
foreign
q)x`
1 2 3
Python dictionaries
Python dictionaries convert to q dictionaries, and vice versa.
References
For more details on using Python in q, see: