KDB-X Python Migration from PyKX¶
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 Python is in beta (marked with a b tag) and under active development. Expect regular updates.
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.
- KDB-X Python operates using KDB-X.
- Status: actively developed; marked with a
btag to indicate beta.
To obtain KDB-X, visit the KDB-X install page.
Key migration changes at a glance¶
- 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
QCFGconfiguration option. Defaults to~/.kx/configif that file exists. - Updated license lookup behavior. KDB-X no longer checks the current working directory for a license. Only
QLICandQHOMEare checked. - Added
.z.vto theZContext. Holds initialization values for:version,QCFG,QHOME,QLIC, andQINIT.
KDB-X Python configuration changes¶
Configuration file location¶
- The default config file has changed from
.pykx-configtoconfig-pykx. PYKX_CONFIGURATION_LOCATIONnow 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
profileargument to specify which profile should receive the configuration values.- Defaults to
kx.config.pykx_config_profile. - Falls back to
defaultif no profile is set.
- Defaults to
- The
folderargument has been replaced withfile.- Defaults to
kx.config.pykx_config_location. - If unset, creates a new file at
~/.kx/config-pykx.
- Defaults to
- Values are no longer added to
os.environ. Configuration is written only to the config file.
kx.util.install_q changes¶
- Added
config_fileargument (defaults topykx_config_location). - Added
config_profileargument (defaults topykx_config_profile).
Removed and replaced options¶
- Removed
PYKX_4_1_ENABLEDconfiguration option. - NEP-49 allocator is now enabled by default to support zero-copy conversions.
- Removed
PYKX_ALLOCATOR. - Added
PYKX_NO_ALLOCATORto opt out. - Removed
--pykxalloc(QARGS/q command-line option). - Added
--pykxnoallocas the new opt-out flag.
- Removed
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.sqlautomatically loads the interface. - From q: call
.s.init[]or start a query withs)– 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=Nto yourQCFGfile.
Release notes¶
KDB-X Python 4.0.0b5¶
Release date: 2025-02-09
- Moves to KDB-X 5.0.20260122.
- Includes bug fixes from PyKX 3.1.6 and PyKX 3.1.7.
-
New
VirtualTableclass for use with Parquet module:>>> import pykx as kx >>> from pathlib import Path >>> pq = kx.q.use('kx.pq') >>> t = pq['pq'](Path('types.parquet')) >>> t pykx.VirtualTable(pykx.q('`T!`f`m`t!(k){[f;t;c;b;a;v]g:$[s:-1h=@b;0;#b];(bf;b1):$[g;df[t;0,0b;b];(::;()..')) >>> t.select() pykx.Table(pykx.q(' col0 col1 col2 --------------- 1 1 "asd" 1 2 "bsd" 0 3 "csd" 1 4 "asd" 0 5 "bsd" 0 6 "csd" 1 7 "asd" 0 8 "bsd" 0 9 "csd" ')) >>> t.select(kx.Column('col1').max(), by=kx.Column('col2')) pykx.KeyedTable(pykx.q(' col2 | col1 -----| ---- "asd"| 7 "bsd"| 8 "csd"| 9 '))
KDB-X Python 4.0.0b4¶
Release date: 2025-11-17
- Moves to KDB-X 5.0.20251114.
- Includes bug fixes from PyKX 3.1.5.
KDB-X Python 4.0.0b3¶
Release date: 2025-09-30 (expired 2026-01-04)
- Moves to KDB-X 0.1.1.
KDB-X Python 4.0.0b2¶
Release date: 2025-07-30 (expired 2025-09-30)
- Removes
invalid escape sequencewarnings upon import for some users. - Turns on NumPy allocator by default.
- Replaces
PYKX_ALLOCATORwithPYKX_NO_ALLOCATOR. - Replaces
--pykxallocwith--pykxnoalloc.
- Replaces
- Includes bug fixes from PyKX 3.1.4.
- Fixed an issue where data could be corrupted in keyed columns of PyArrow-backed Pandas dataframes.
- Resolved
object has no attribute 't'error for certain conversions.
KDB-X Python 4.0.0b1¶
Release date: 2025-07-02 (expired 2025-09-30)
- Initial release. Uses KDB-X 0.1.0.
Next steps¶
KDB-X Python continues to evolve with the KDB-X platform. For upcoming changes and recent updates, refer to: