Skip to content

Migrating from PyKX 3.* to KDB-X Python 4.*

This page outlines the key changes that affect developers moving from PyKX (pykx~=3.0) to KDB-X Python (pykx>=4.0). It covers updated configuration behavior, new defaults, deprecated options, and important differences in how SQL, threading, and cloud libraries load.

KDB-X and Python integration

KDB-X is the evolution of kdb+. KDB-X Python is the evolution of PyKX, and now develops directly alongside the KDB-X platform – new KDB-X features integrate rapidly and completely into the Python library.

To obtain KDB-X and a license, visit the KDB-X install page.

Key migration changes at a glance

  • KDB-X Python operates using KDB-X (unlike PyKX which used kdb+ 4.0/4.1).
  • Configuration is now primarily managed through configuration files; environment variables are still supported and take precedence.
  • Cloud libraries are no longer loaded by default – they have moved from opt-out to opt-in.
  • The SQL interface is embedded directly into KDB-X and is auto-loaded on first use.
  • The NEP-49 allocator is now enabled by default (opt-out instead of opt-in).
  • No default value for secondary threads.

KDB-X configuration changes

For the full list of platform changes, refer to the KDB-X release notes. The updates below directly impact KDB-X Python:

  • Added QCFG configuration option. Defaults to ~/.kx/config if that file exists.
  • Updated license lookup behavior. KDB-X no longer checks the current working directory for a license. Only QLIC and QHOME are checked.
  • Added .z.v to the ZContext. Holds initialization values for: version, QCFG, QHOME, QLIC, and QINIT.

KDB-X Python configuration changes

Configuration file location

  • The default config file has changed from .pykx-config to config-pykx.
  • PYKX_CONFIGURATION_LOCATION now points to a file, not a folder. Users can set a custom filename if needed.
  • Configuration is searched in this order:
  • PYKX_CONFIGURATION_LOCATION (if set)
  • ~/.kx/config-pykx (if it exists)
  • The current directory (.) and home directory (~) are no longer searched.

kx.util.add_to_config changes

  • Added a profile argument to specify which profile should receive the configuration values.
  • Defaults to kx.config.pykx_config_profile.
  • Falls back to default if no profile is set.
  • The folder argument has been replaced with file.
  • Defaults to kx.config.pykx_config_location.
  • If unset, creates a new file at ~/.kx/config-pykx.
  • Values are no longer added to os.environ. Configuration is written only to the config file.

kx.util.install_q changes

  • Added config_file argument (defaults to pykx_config_location).
  • Added config_profile argument (defaults to pykx_config_profile).

Removed and replaced options

  • Removed PYKX_4_1_ENABLED configuration option.
  • NEP-49 allocator is now enabled by default to support zero-copy conversions.
  • Removed PYKX_ALLOCATOR.
  • Added PYKX_NO_ALLOCATOR to opt out.
  • Removed --pykxalloc (QARGS / CLI).
  • Added --pykxnoalloc as the new opt-out flag.

Library loading and command-line changes

Cloud library loading

KDB-X Python no longer loads cloud libraries (kurl, objstor, qlog, sql) by default on import. These libraries have moved from opt-out to opt-in in order to:

  • Speed up imports.
  • Prevent errors and warnings for users who don't need these features.

Libraries must now be explicitly enabled using the environment variables or QARGS flags below.

Environment variable changes

Removed Replacement
PYKX_NOQCE PYKX_QCE

QARGS flag updates

The following flags have moved from opt-out to opt-in:

Removed flag Replacement
--no-qce --qce
--no-kurl --kurl
--no-objstor --objstor
--no-qlog --qlog
--no-sql --sql

SQL interface changes

KDB-X now embeds its SQL interface directly, eliminating the need to load it from an external file (s.k_).

You can initialize the SQL interface in any of the following ways:

  • Set any of: QARGS="--qce", QARGS="--sql", PYKX_QCE=True.
  • From Python: the first call to kx.q.sql automatically loads the interface.
  • From q: call .s.init[] or start a query with s) – both auto-load on first use.

Note

If your code calls .s functions directly by name (for example, .s.e), ensure the SQL interface is loaded before those calls run using one of the methods above.

Threading behavior

KDB-X Python no longer sets a default value for secondary threads. To enable them:

  • Set QARGS="-s N", or
  • Add s=N to your QCFG file.

Changelog

For the full changelog, refer to the KDB-X Python changelog.