Skip to content

New Documentation Site!

We are excited to announce the launch of our enhanced product documentation site for PyKX at docs.kx.com. It offers improved search capabilities, organized navigation, and developer-focused content. Please, take a moment to explore the site and share your feedback with us.

System command wrappers

pykx.system

System command wrappers for PyKX.

SystemCommands

SystemCommands(q)

Wrappers for q system commands.

More documentation on all the system commands available to q can be found here.

tables

tables(namespace=None)

Lists the tables associated with a namespace/dictionary

Examples:

Retrieve the tables within a provided namespace:

kx.system.tables('.foo')

Retrieve the tables within a provided dictionary:

kx.system.tables('foo')

console_size writable property

console_size()

The maximum console size for the q process in the format rows, columns.

The size of the output for the q process before truncating the rest with ....

Expects a 2 item list denoting the console width and console height.

Note: Does not work over IPC, only within EmbeddedQ.

Examples:

Get the maximum console_size size of output for EmbeddedQ to 10 columns and 10 rows.

kx.q.system.console_size

Set the maximum console size of output for EmbeddedQ to 10 columns and 10 rows.

kx.q.system.console_size = [10, 10]

display_size writable property

display_size()

The maximum console display size for the q process in the format rows, columns.

The size of the output for the q process before truncating the rest with ....

Expects a 2 item list denoting the display width and console height.

Note: Does not work over IPC, only within EmbeddedQ.

Examples:

Get the maximum display size of output for EmbeddedQ to 10 columns and 10 rows.

kx.q.system.display_size

Set the maximum display size of output for EmbeddedQ to 10 columns and 10 rows.

kx.q.system.display_size = [10, 10]

cd

cd(directory=None)

Get the current directory or change the current directory.

Examples:

Get the current working directory.

kx.q.system.cd()

Change the current working directory to the root directory on a UNIX like machine.

kx.q.system.cd('/')

namespace

namespace(ns=None)

Get the current namespace or change to a new namespace.

Examples:

Get the current namespace.

kx.q.system.namespace()

Change the current namespace to .foo, note the leading . may be ommited.

kx.q.system.namespace('foo')

Return to the default namespace.

kx.q.system.namespace('')

functions

functions(ns=None)

Get the functions available in the current namespace or functions in a provided namespace or dictionary.

Examples:

Get the functions within the current namespace.

kx.q.system.functions()

Get the functions within the .foo namespace.

kx.q.system.functions('.foo')

Get the functions within a dictionary.

kx.q.system.function('foo')

garbage_collection writable property

garbage_collection()

The current garbage collection mode that q will use.

0 - default deferred collection. 1 - immediate collection.

Examples:

Get the current garbage collection mode.

kx.q.system.garbage_collection

Set the current garbage collection mode to immediate collection.

kx.q.system.garbage_collection = 1

load

load(path)

Loads a q script or a directory of a splayed table.

Examples:

Load a q script named foo.q.

kx.q.system.load('foo.q')

utc_offset writable property

utc_offset()

Get the local time offset as an integer from UTC.

If abs(offset) > 23 then return the offset in minutes.

Examples:

Get the current local time offset.

kx.q.system.utc_offset

Set the current local time offset to be -4:00 from UTC.

kx.q.system.utc_offset = -4

precision writable property

precision()

Get the precision for floating point numbers (number of digits shown).

Note: Setting this property does not work over IPC, only works within EmbeddedQ.

Examples:

Get the current level of float precision.

kx.q.system.precision

Set the Level of float precision to 2.

kx.q.system.precision = 2

rename

rename(src, dest)

Rename file src to dest.

Equivalent to the unix mv command or Windows move command.

Note: Cannot rename to a different disk.

Examples:

Rename a file foo.q to bar.q.

kx.q.system.rename('foo.q', 'bar.q')

max_num_threads writable property

max_num_threads()

The maximum number of secondary threads available to q.

This value can be set using the -s command-line flag, provided to q via the $QARGS environment variable. For example: QARGS='-s 8' python, or QARGS='-s 0' python.

num_threads writable property

num_threads()

The current number of secondary threads being used by q.

Computations in q will automatically be parallelized across this number of threads as q deems appropriate.

This property is meant to be modified on EmbeddedQ and QConnection instances.

Examples:

Set the number of threads for embedded q to use to 8.

kx.q.num_threads = 8

Set the number of threads for a q process being connected to over IPC to 8.

q = kx.SyncQConnection('localhost', 5001)
q.num_threads = 8

random_seed writable property

random_seed()

The last value the the random seed was initialized with.

Examples:

Get the current seed value.

kx.q.system.random_seed

Set the random seed value to 23.

kx.q.system.random_seed = 23

variables

variables(ns=None)

Get the variables in the current namespace or variables in a given namespace.

Examples:

Get the variables defined in the current namespace.

kx.q.system.variables()

Get the variables associated with a q namespace/dictionary

kx.q.system.variables('.foo')
kx.q.system.variables('foo')

workspace property

workspace()

Outputs various information about the current memory usage of the q process.

Examples:

Get the memory usage of EmbeddedQ.

kx.q.system.workspace

week_offset writable property

week_offset()

The start of week offset where 0 is Saturday.

Examples:

Get the current week offset.

kx.q.system.week_offset

Set the current week offset so Monday is the first day of the week.

kx.q.system.week_offset = 2

date_parsing writable property

date_parsing()

Get the current format for date parsing.

0 - is for mm/dd/yyyy 1 - is for dd/mm/yyyy

Examples:

Get the current value for date parsing.

kx.q.system.date_parsing

Get the current value for date parsing so the format is dd/mm/yyyy.

kx.q.system.date_parsing = 1