Changelog
PyKX 1.5.4
Additions
- Wheels for ARM64 based Macs are now available for download.
PyKX 1.5.3
Additions
- Added support for Pandas Float64Index.
PyKX 1.5.2
Additions
- Added support for ARM 64 Linux.
PyKX 1.5.1
Fixes and Improvements
- Fixed an issue with pykx.qthat caused errors to not be raised properly under q.
- Fixed an issue when using .pykx.getand.pykx.getattrthat caused multiple calls to be made.
PyKX 1.5.0
Additions
- Added wrappers around various qsystem commands.
- Added mergemethod to tables when using thePandas API.
- Added mean/median/modefuctions to tables when using thePandas API.
- Added various functions around type conversions on tables when using the Pandas API.
Fixes and Improvements
- Fix to allow GUIDs to be sent over IPC.
- Fix an issue related to IPC connection using compression.
- Improved the logic behind loading pykx.qunder aqprocess allowing it to run on MacOS and Linux in any environment thatEmbedPyworks in.
- Fix an issue that cause the default handler for SIGINTto be overwritten.
- pykx.toq.from_callablereturns a- pykx.Compositionrather than- pykx.Lambda. When executed returns an unwrapped q object.
- Fixed conversion of Pandas Timestamp objects.
- Fixed an issue around the PyKXqmagic command failing to load properly.
- Fixed a bug around conversions of Pandastables with no column names.
- Fixed an issue around .pykx.qevalnot returning unwrapped results in certain scenarios.
PyKX 1.4.2
Fixes and Improvements
- Fixed an issue that would cause EmbeddedQto fail to load.
PyKX 1.4.1
Fixes and Improvements
- Added constructors for TableandKeyedTableobjects to allow creation of these objects from dictionaries and list like objects.
- Fixed a memory leak around calling wrapped Foreignobjects inpykx.q.
- Fixed an issue around the tlskeyword argument when creatingQConnectioninstances, as well as a bug in the unlicensed behaviour ofSecureQConnection's.
PyKX 1.4.0
Additions
- Addition of a utility function kx.ssl_info()to retrieve the SSL configuration when running in unlicensed mode (returns the same info as kx.q('-26!0') with a license).
- Addition of a utility function kx.schema.builderto allow for the generation ofpykx.Tableandpykx.KeyedTabletypes with a defined schema and zero rows, this provides an alternative to writing q code to create an empty table.
- Added helper functions for inserting and upserting to k.Tableinstances. These functions provide new keyword arguments to run a test insert against the table or to enforce that the schema of the new row matches the existing table.
- Added environment variable PYKX_NOQCE=1to skip the loading of q Cloud Edition in order to speed up the import of PyKX.
- Added environment variable PYKX_LOAD_PYARROW_UNSAFE=1to import PyAarrow without the "subprocess safety net" which is here to prevent some hard crashes (but is slower than a simple import).
- Addition of method file_executetokx.QConnectionobjects which allows the execution of a local.qscript on a server instance as outlined here.
- Added kx.RawQConnectionwhich extendskx.AsyncQConnectionwith extra functions that allow a user to directly poll the send and receive selectors.
- Added environment variable PYKX_RELEASE_GIL=1to drop thePython GILon calls into embedded q.
- Added environment variable PYKX_Q_LOCK=1to enable a Mutex Lock around calls into q, setting this environment variable to a number greater than 0 will set the max length in time to block before raising an error, a value of '-1' will block indefinitely and will not error, any other value will cause an error to be raised immediately if the lock cannot be acquired.
- Added insertandupsertmethods toTableandKeyedTableobjects.
Fixes and Improvements
- Fixed has_nullsandhas_infsproperties for subclasses ofk.Collection.
- Improved error output of kx.QConnectionobjects when an error is raised within the context interface.
- Fixed .py()conversion of nestedk.Dictionaryobjects and keyedk.Dictionaryobjects.
- Fixed unclear error message when querying a QConnectioninstance that has been closed.
- Added support for conversions of non C contiguous numpy arrays.
- Fixed conversion of null GUIDAtom's to and from numpy types.
- Improved performance of converting qenums to pandas Categoricals.
Beta Features
- Added support for a Pandas like API around TableandKeyedTableinstances, documentation for the specific functionality can be found here.
- Added .pykx.setdefaulttopykx.qwhich allows the default conversion type to be set without using environment variables.
PyKX 1.3.2
Features and Fixes
- Fixed support for using TLS with SyncQConnectioninstances.
PyKX 1.3.1
Features and Fixes
- Added environment variable PYKX_Q_LIB_LOCATIONto specify a path to load the PyKX q libraries from.- Required files in this directory- If you are using the kdb+/q Insights core libraries they all must be present within this folder.
- The read.q,write.q, andcsvutil.qlibraries that are bundled with PyKX.
- A q.kthat matches the version ofqyou are loading.
- There must also be a subfolder (l64/m64/w64) based on the platform you are using.- Within this subfolder a copy of these files must also be present.- libq.(so / dylib)/- q.dll.
- libe.(so / dylib)/- e.dll.
- If using the Insights core libraries their respective shared objects must also be present here.
 
 
- Within this subfolder a copy of these files must also be present.
 
 
- Required files in this directory
- Updated core q libraries- PyKX now supports M1 Macs
- OpenSSLv3 support
 
- Added ability to specify maximum length for IPC error messages. The default is 256 characters and this can be changed by setting the PYKX_MAX_ERROR_LENGTHenvironment variable.
PyKX 1.3.0
Features and Fixes
- Support for converting datetime.datetimeobjects with timezone information intopykx.TimestampAtoms andpykx.TimestampVectors.
- Added a magic command to run cells of q code in a Jupyter Notebook. The addition of %%qat the start of a Jupyter Notebook cell will allow a user to execute q code locally similarly to loading a q file.
- Added no_ctxkey word argument topykx.QConnectioninstances to disable sending extra queries to/from q to manage the context interface.
- Improvements to SQL interface for PyKX including the addition of support for prepared statements, execution of these statements and retrieval of inputs see here for more information.
- Fix to memory leak seen when converting Pandas Dataframes to q tables.
- Removed unnecessary copy when sending qobjects over IPC.
Beta Features
- EmbedPy replacement functionality pykx.qupdated significantly to provide parity with embedPy from a syntax perspective. Documentation of the interface here provides API usage. Note that initialisation requires the first version of Python to be retrieved on a usersPATHto have PyKX installed. Additional flexibility with respect to installation location is expected in1.4.0please provide any feedback topykx@kx.com
PyKX 1.2.2
Features and Fixes
- Fixed an issue causing the timeout argument for QConnectioninstances to not work work properly.
PyKX 1.2.1
Features and Fixes
- Added support for OpenSSLv3 for IPC connections created when in 'licensed' mode.
- Updated conversion functionality for timestamps to support conversions within Pandas 1.5.0
PyKX 1.2.0
Features and Fixes
- Support for converting any python type to a qForeign object has been added.
- Support for converting Pandas categorical types into pykx.EnumVectortype objects.
- Support for q querying against Pandas/PyArrow tables through internal conversion to q representation and subsequent query. kx.q.qsql.select(<pd.DataFrame>)
- Support for casting Python objects prior to converting into K objects. (e.g. kx.IntAtom(3.14, cast=True)orkx.toq("3.14", ktype=kx.FloatAtom, cast=True)).
- Support usage of numpy __array_ufunc__'s directly onpykx.Vectortypes.
- Support usage of numpy __array_function__'s directly onpykx.Vectortypes (Note: these will return a numpy ndarray object not an analogouspykx.Kobject).
- Improved performance of pykx.SymbolVectorconversion into native Python type (e.g..py()conversion forpykx.SymbolVector's).
- Improved performance and memory usage of various comparison operators between Ktypes.
- Improved performance of various pykx.toqconversions.
- pykx.Vectortypes will now automatically enlist atomic types instead of erroring.
- Fixed conversions of numpy float types into pykx.FloatAtomandpykx.RealAtomtypes.
- Fixed conversion of NonePython objects into analogous nullKtypes if aktypeis specified.
- Added event_loopparameter topykx.AsyncQConnectionthat takes a running event loop as a parameter and allows the event loop to managepykx.QFutureobjects.
Beta Features
- Added extra functionality to pykx.qrelated to the calling and use of python foreign objects directly within aqprocess.
- Support for NEP-49, which allows numpy arrays to be converted into qVectors without copying the underlying data. This behaviour is opt-in and you can do so by setting the environment variablePYKX_ALLOCATORto 1, "1" or True or by adding the flag--pykxallocto theQARGSenvironment variable. Note: This feature also requires a python version of at least 3.8.
- Support the ability to trigger early garbage collection of objects in the qmemory space by adding--pykxgcto the QARGS environment variable, or by setting thePYKX_GCenvironment variable to 1, "1" or True.
PyKX 1.1.1
Features & Fixes
- Added ability to skip symlinking $QHOMEtoPyKX's local$QHOMEby setting the environment variableIGNORE_QHOME.
PyKX 1.1.0
Dependencies
- The dependency on the system library libcurlhas been made optional for Linux. If it is missing on Linux, a warning will be emitted instead of an error being raised, and the KX Insights Core librarykurlwill not be fully loaded. Windows and macOS are unaffected, as they don't support the KX Insights Core features to begin with.
Features & Fixes
- Splayed and partitioned tables no longer emit warnings when instantiated.
- Added pykx.Q.sql, which is a wrapper around KXI Core SQL.
- .pykx.pyexecand- .pykx.pyevalno longer segfault when called with a character atom.
- Updated several pykx.toqtests so that they would not randomly fail.
- Fixed error when pickling pykx.util.BlockManagerin certain esoteric situations.
- Fixed pandas.MultiIndexobjects created by PyKX havingpykx.SymbolAtomobjects within them - now they havestrobjects instead, as they normally would.
- Upgraded the included KX Insights Core libraries to version 3.0.0.
- Added pykx.toq.from_datetime_date, which convertsdatetime.dateobjects into any q temporal atom that can represent a date (defaulting to a date atom).
- Fixed error when user specifies -sor-qin$QARGS.
- Fixed recursion error when accessing a non-existent attribute of pykx.qwhile in unlicensed mode. Now an attribute error is raised instead.
- Fixed build error introduced by new rules enforced by new versions of setuptools.
- Added pykx.Anymap.
- Fixed support for kx.liclicenses.
- The KXIC libraries are now loaded after q has been fully initialized, rather than during the initialization. This significantly reduces the time it takes to import PyKX.
- PyKX now uses a single location for $QHOME: itslibdirectory within the installed package. The top-level contents of the$QHOMEdirectory (prior to PyKX updating the env var when embedded q is initialized) will be symlinked into PyKX'slibdirectory, along with the content of any subdirectories underlib(e.g.l64,m64,w64). This enables loading scripts and libraries located in the original$QHOMEdirectory during q initialization.
- Improved performance (both execution speed and memory usage) of calling np.arrayonpykx.Vectorinstances. The best practice is still to use thenpmethod instead of callingnp.arrayon thepykx.Vectorinstance.
- pykx.Vectoris now a subclass of- collections.abc.Sequence.
- pykx.Mappingis not a subclass of- collections.abc.Mapping.
- Split pykx.QConnectionintopykx.SyncQConnectionandpykx.AsyncQConnectionand added support for asynchronous IPC withqusingasync/await. Refer to thepykx.AsyncQConnectiondocs for more details.
- Pandas dataframes containing Pandas extension arrays not originally created as Numpy arrays would result in errors when attempting to convert to q. For example a Dataframe with index of type pandas.MultiIndex.from_arrayswould result in an error in conversion.
- Improved performance of converting pykx.SymbolVectortonumpy.arrayof strings, and also the conversion back from anumpy.arrayofstringsto aqSymbolVector.
- Improved performance of converting numpy.array's ofdtypesdatetime64/timedelta64to the variouspykx.TemporalTypes.
PyKX 1.0.1
Deprecations & Removals
- The syncparameter forpykx.QConnectionandpykx.QConnection.__call__has been renamed to the less confusing namewait. Thesyncparameter remains, but its usage will result in aDeprecationWarningbeing emitted. Thesyncparameter will be removed in a future version.
Features & Fixes
- Updated to stable classifier (Development Status :: 5 - Production/Stable) in project metadata. Despite this update being done in version 1.0.1, version 1.0.0 is still the first stable release of PyKX.
- PyKX now provides source distributions (sdist). It can be downloaded from PyPI usingpip download --no-binary=:all: --no-deps pykx. As noted in the installation docs, installations built from the source will only receive support on a best-effort basis.
- Fixed Pandas NaT conversion to q types. Now pykx.toq(pandas.NaT, ktype=ktype)produces a null temporal atom for any givenktype(e.g.pykx.TimeAtom).
- Added a doc page for limitations of embedded q.
- Added a test to ensure large vectors are correctly handled (5 GiB).
- Always use synchronous queries internally, i.e. fix QConnection(sync=False).
- Disabled the context interface over IPC. This is a temporary measure that will be reversed once q function objects are updated to run in the environment they were defined in by default.
- Reduced the time it takes to import PyKX. There are plans to reduce it further, as import pykxremains fairly slow.
- Updated to KXI Core 2.1 & rename qce->kxic.
- Misc test updates.
- Misc doc updates.
PyKX 1.0.0
Migration Notes
To switch from Pykdb to PyKX, you will need to update the name of the dependency from pykdb to pykx in your pyproject.toml/requirements.txt/setup.cfg/etc. When Pykdb was renamed to PyKX, its version number was reset. The first public release of PyKX has the version number 1.0.0, and will employ semantic versioning.
Pay close attention to the renames listed below, as well as the removals. Many things have been moved to the top-level, or otherwise reorganized. A common idiom with Pykdb was the following:
from pykdb import q, kIt is recommended that the following be used instead:
import pykx as kxThis way the many attributes at the top-level can be easily accessed without any loss of context, for example:
kx.q # Can be called to execute q code
kx.K # Base type for objects in q; can be used to convert a Python object into a q type
kx.SymbolAtom # Type for symbol atoms; can be used to convert a `str` or `bytes` into a symbol atom
kx.QContext # Represents a q context via the PyKX context interface
kx.QConnection # Can be called to connect to a q process via q IPC
kx.PyKXException # Base exception type for exceptions specific to PyKX and q
kx.QError # Exception type for errors that occur in q
kx.LicenseException # Exception type raised when features that require a license are used without
kx.QHOME # Path from which to load q files, set by $QHOME environment variable
kx.QARGS # List of arguments provided to the embedded q instance at startup, set by $QARGS environment variable
# etc.You can no longer rely on the context being reset to the global context after each call into embedded q, however IPC calls are unaffected.
Renames
- Pykdb has been renamed to PyKX. Pykdb->PyKX;PYKDB->PYKX;pykdb->pykx.
- The adaptmodule has been renamed totoq, and it can be called directly. Instead ofpykdb.adapt.adapt(x)one should writepykx.toq(x).
- The kmodule has been renamed towrappers. All wrapper classes can be accessed from the top-level, i.e.pykx.K,pykx.SymbolAtom, etc.
- The "module interface" (pykdb.module_interface) has been renamed to the "context interface" (pykx.ctx). Allpykx.Qinstances (i.e.pykx.qand allpykx.QConnectioninstances) have actxattribute, which is the globalQContextfor thatpykx.Qinstance. Usually, one need not directly access the global context. Instead, one can access its subcontexts directly e.g.q.dbmaintinstead ofq.ctx.dbmaint.
- KdbError(and its subclasses) have been renamed to- QError
- pykdb.ctx.KdbContexthas been renamed to- pykx.ctx.QContext, and is available from the top-level, i.e.- pykx.QContext.
- The Connectionclass in the IPC module has been renamed toQConnection, and is now available at the top-level, i.e.pykx.QConnection.
- The q type wrapper DynamicLoadhas been renamed toForeign(pykdb.k.DynamicLoad->pykx.Foreign).
Deprecations & Removals
- The pykdb.q.ipcattribute has been removed. The IPC module can be accessed directly instead atpykx.ipc, but generally one will only need to access theQConnectionclass, which can be accessed at the top-level:pykx.QConnection.
- The pykdb.q.Kattribute has been removed. Instead,Ktypes can be used as constructors for that type by leveraging thetoqmodule. For example, instead ofpykdb.q.K(x)one should writepykx.K(x). Instead ofpykx.q.K(x, k_type=pykx.k.SymbolAtom)one should writepykx.SymbolAtom(x)orpykx.toq(x, ktype=pykx.SymbolAtom).
- Most KdbError/QErrorsubclasses have been removed, as identifying them is error prone, and we are unable to provide helpful error messages for most of them.
- The pykx.kdbsingleton class has been removed.
Dependencies
- More Numpy, Pandas, and PyArrow versions are supported. Current pandas~=1.0,numpy~=1.20,<1.22, andpyarrow>=3.0.0are supported. PyArrow remains an optional dependency.
- A dependency on find-libpython~=0.2was added. This is only used when running PyKX under a q process (see details in the section below about new alpha features).
- A dependency on the system library libcurlwas added for Linux. This dependency will be made optional in a future release.
Features & Fixes
- The pykx.Qclass has been added as the base class forpykx.EmbeddedQ(the class forpykx.q) andpykx.QConnection.
- The pykx.EmbeddedQprocess now perisists its context between calls.
- The console now works over IPC.
- The query module now works over IPC. Because Kobjects hold no reference to theqinstance that created them (be it local or over IPC),Ktables no longer haveselect/exec/update/deletemethods with themselves projected in as the first argument. That is to say, instead of writingt.select(...), writeq.qsql.select(t, ...), whereqis eitherpykx.qor an instance ofpykx.QConnection, andtwas obtained fromq.
- The context interface now works over IPC.
- Nulls and infinities are now handled as nulls and infinities, rather than as their underlying values. pykx.Atom.is_null,pykx.Atom.is_inf,pykx.Collection.has_nulls, andpykx.Collection.has_infshave been added. Numpy, Pandas, and PyArrow handles integral nulls with masked arrays, and they handle temporal nulls withNaT.NaNcontinues to be used for real/float nulls. The general Python representation (from.py()) usesKobjects for nulls and infinities.
- Calling boolonpykx.Kobjects now either raises aTypeError, or return the unambiguously correct result. For ambiguous cases such aspykx.Collectioninstances, use.any(),.all(), or a length check instead.
- Assignment to q reserved words or the q context now raises a pykx.PyKXException.
- pykx.toq.from_list(previously- pykdb.adapt.adapt_list) now works in unlicensed mode.
- q.queryand- q.sqlare now placeholders (set to- None). The query interface can be accessed from- q.qsql.
- Ternary pownow raisesTypeErrorforRealNumericVectorandRealNumericAtom.
- QContextobjects are now context handlers, e.g.- with pykx.q.dbmaint: # operate in .dbmaint within this block. This context handler supports arbitrary nesting.
- __getitem__now raises a- pykx.LicenseExceptionwhen used in unlicensed mode. Previously it worked for a few select types only. If running in unlicensed mode, one should perform all q indexing in the connected q process, and all Python indexing after converting the- Kobject to a Python/Numpy/Pandas/PyArrow object.
- pykx.QConnection(previously- pykdb.ipc.Connection) objects now have an informative/idiomatic repr.
- Calls to pykx.qnow support up to 8 arguments beyond the required query at position 0, similar to callingpykx.QConnectioninstances. These arguments are applied to the result of the query.
- Embedded q is now used to count the number of rows a table has.
- All dynamic linking to libqandlibehas been replaced by dynamic loading. As a result, the modules previously known asadaptandadapt_unlicensedhave been unified underpykx.toq.
- PyKX now attempts to initialize embedded q when pykxis imported, rather than whenpykx.qis first accessed. As a result, the error-prone practice of supplying thepykx.kdbsingleton class with arguments for embedded q is now impossible.
- Arguments for embedded q can now be supplied via the environment variable $QARGSin the form of command-line arguments. For example,QARGS='--unlicensed'causes PyKX to enter unlicensed mode when it is started, andQARGS='-o 8'causes embedded q to use an offset from UTC of 8 hours. These could be combined asQARGS='--unlicensed -o 8'.
- Added the --licensedstartup flag (to be provided via the$QARGSenvironment variable), which can be used to raise apykx.PyKXException(rather than emitting a warning) if PyKX fails to start in licensed mode (likely because of a missing/invalid q license).
- PyKX Linux wheels are now PEP 600 compliant, built to the manylinux_2_17standard.
- Misc other bug fixes.
- Misc doc improvements.
Performance Improvements
- Converting nested lists from q to Python is much faster.
- Internally, PyKX now calls q functions with arguments directly instead of creating a pykx.Functioninstance then calling it. This results in modest performance benefits in some cases.
- The context interface no longer loads every element of a context when the context is first accessed, thereby removing the computation spike, which could be particularly intense for large q contexts.
New Alpha Features
Alpha features are subject to change
Alpha features are not stable will be subject to changes without notice. Use at your own risk.
- q can now load PyKX by loading the q file pykx.q.pykx.qcan be copied into$QHOMEby runningpykx.install_into_QHOME(). When loaded into q, it will define the.pykxnamespace, which notably has.pykx.execand.pykx.pyeval. This allows for Python code to be run within q libraries and applications without some of the limitations of embedded q such as the lack of the q main loop, or the lack of timers. When q loadspykx.q, it attempts to source the currently active Python environment by runningpython, then fetching the environment details from it.