# PyKX 2.4.0 Released!

**URL:** <https://forum.kx.com/t/pykx-2-4-0-released/13843>\
**Category:** Community Support\
**Tags:** pykx, imported\
**Created:** [March 21, 2024, 9:22am UTC](https://forum.kx.com/t/pykx-2-4-0-released/13843 "2024-03-21T09:22:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmccarthy1](https://avatars.discourse-cdn.com/v4/letter/c/dec6dc/32.png) [@cmccarthy1](https://forum.kx.com/u/cmccarthy1)\
**Post date:** [March 21, 2024, 9:22am UTC](https://forum.kx.com/t/pykx-2-4-0-released/13843/1 "2024-03-21T09:22:24Z")

</div>

[https://learninghub.kx.com/forums/topic/pykx-2-4-0-released](https://learninghub.kx.com/forums/topic/pykx-2-4-0-released)

Hi all,

PyKX 2.4.0 has been released. Full details on the release can be found [here](https://code.kx.com/pykx/2.4/release-notes/changelog.html#pykx-240).

**_Additions_**

- Support for q/kdb+ **4.1** documentation [here](https://code.kx.com/q/releases/ChangesIn4.1/?_gl=1*xp2ofe*_ga*NTc1NjQ4NzQuMTY5MzU2NTQzMg..*_ga_96WX6WQP6Y*MTcxMTAxMjc4My4zNy4xLjE3MTEwMTQwOTIuNjAuMC42MDc3MDUzNTA.) added as an opt-in capability, this functionality is enabled through setting **PYKX\_4\_1\_ENABLED** environment variable.

```
\>\>\> import os

\>\>\> os.environ['PYKX\_4\_1\_ENABLED'] = 'True'

\>\>\> import pykx as kx

\>\>\> kx.q.z.K

pykx.FloatAtom(pykx.q('4.1'))
```

- Added support for Python **3.12**
  - Support for PyArrow in this python version is currently in Beta.

- Added conversion of NumPy arrays of type **datetime64[s]**, **datetime64[ms], datetime64[us]** to **kx.TimestampVector**
- Added [Table.sort\_values()](https://code.kx.com/pykx/2.4/user-guide/advanced/Pandas_API.html#tablesort_values), [Table.nsmallest()](https://code.kx.com/pykx/2.4/user-guide/advanced/Pandas_API.html#tablensmallest) and [Table.nlargest()](https://code.kx.com/pykx/2.4/user-guide/advanced/Pandas_API.html#tablenlargest) to the Pandas like API for sorting tables.
- **Table.rename()** now supports non-numerical index columns and improved the quality of errors thrown.

- Added the **reconnection\_attempts** key word argument to **SyncQConnection** , **SecureQConnection** , and **AsyncQConnection 0** IPC classes. This argument allows IPC connection to be automatically re-established when it is lost and a server has reinitialized.

```
\>\>\> import pykx as kx

\>\>\> conn = kx.SyncQConnection(port = 5050, reconnection\_attempts=4)

\>\>\> conn('1+1') # Following this call the server on port 5050 was closed for 2 seconds

pykx.LongVector(pykx.q('2'))

\>\>\> conn('1+2')

WARNING: Connection lost attempting to reconnect. Failed to reconnect, trying again in 0.5 seconds.

Failed to reconnect, trying again in 1.0 seconds.

Connection successfully reestablished.

pykx.LongAtom(pykx.q('3'))
```

- Added **--reconnection\_attempts** option to Jupyter **%%q** magic making use of the above IPC logic changes.
- Addition of environment variable/configuration value **PYKX\_QDEBUG** which allows debugging backtrace to be displayed for all calls into q instead of requiring a user to specify debugging is enabled per-call. This additionally works for remote IPC calls and utilisation of Jupyter magic commands.

```
\>\>\> import os

\>\>\> os.environ['PYKX\_QDEBUG'] = 'True'

\>\>\> import pykx as kx

\>\>\> kx.q('{x+1}', 'e')

backtrace:

[2] {x+1}

^

[1] (.Q.trp)

[0] {[pykxquery] .Q.trp[value; pykxquery; {if[y~();:(::)];2@"backtrace:

^

",.Q.sbt y;'x}]}

Traceback (most recent call last):

File "", line 1, in

File "/usr/local/anaconda3/lib/python3.8/site-packages/pykx/embedded\_q.py", line 230, in \_\_call\_\_

return factory(result, False)

File "pykx/\_wrappers.pyx", line 493, in pykx.\_wrappers.\_factory

File "pykx/\_wrappers.pyx", line 486, in pykx.\_wrappers.factory

pykx.exceptions.QError: type
```

**_Fixes and Improvements_**

- Resolved segfaults on Windows when PyKX calls Python functions under q.

```
\>\>\> import pykx as kx

\>\>\> kx.q('{[f;x] f x}', sum, kx.q('4 4#til 16'))

pykx.LongVector(pykx.q('24 28 32 36'))
```

- Updated kdb Insights Core libraries to 4.0.8, see [here](https://code.kx.com/insights/1.8/core/release-notes/latest.html?_gl=1*tod0c*_ga*NTc1NjQ4NzQuMTY5MzU2NTQzMg..*_ga_96WX6WQP6Y*MTcxMTAxMjc4My4zNy4xLjE3MTEwMTUwNTEuNDYuMC42MDc3MDUzNTA.#408) for more information.
- Updated **libq** 4.0 version to 2024.03.04 for all supported OS’s.
- Fix issue where use of valid C backed q **code** APIs could result in segmentation faults when called.

```
\>\>\> import pykx as kx

\>\>\> isf = kx.q('.pykx.util.isf')

\>\>\> isf

pykx.Foreign(pykx.q('code'))

\>\>\> isf(True)

pykx.BooleanAtom(pykx.q('0b'))
```

- Each call to the PyKX query API interned 3 new unique symbols. This has now been removed.

**_Beta Features_**

- Addition of **Compress** and **Encrypt** classes to allow users to set global configuration and for usage within Database partition persistence.

_Standalone_

```
\>\>\> import pykx as kx

\>\>\> compress = kx.Compress(algo=kx.CompressionAlgorithm.gzip, level=8)

\>\>\> kx.q.z.zd

pykx.Identity(pykx.q('::'))

\>\>\> compress.global\_init()

pykx.LongVector(pykx.q('17 2 8'))

\>\>\> encrypt = kx.Encrypt(path='/path/to/the.key', password='PassWord')

\>\>\> encrypt.load\_key()
```

_Database_

```
\>\>\> import pykx as kx

\>\>\> compress = kx.Compress(algo=kx.CompressionAlgorithm.lz4hc, level=10)

\>\>\> db = kx.DB(path='/tmp/db')

\>\>\> db.create(kx.q('([]10?1f;10?1f)', 'tab', kx.q('2020.03m'), compress=compress)

\>\>\> kx.q('-21!`:/tmp/db/2020.03/tab/x')

pykx.Dictionary(pykx.q('

compressedLength | 140

uncompressedLength| 96

algorithm | 4i

logicalBlockSize | 17i

zipLevel | 10i

'))
```

---

<div class="post-metadata">

**Author:** ![mmcparland](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/mmcparland/32/54_2.png) [@mmcparland](https://forum.kx.com/u/mmcparland)\
**Post date:** [March 21, 2024, 10:17am UTC](https://forum.kx.com/t/pykx-2-4-0-released/13843/2 "2024-03-21T10:17:15Z")

</div>

Thanks for sharing @cmccarthy1 !?
