mirror of
https://github.com/hanzo-ds/connect.git
synced 2026-10-30 20:31:24 +00:00
* declare free-threading compatibility for the Cython extensions, test 3.14t * update test matrix server vers * exclude polars from 3.14t test
18 lines
582 B
Cython
18 lines
582 B
Cython
# cython: freethreading_compatible = True
|
|
import cython
|
|
|
|
import numpy as np
|
|
|
|
from .buffer cimport ResponseBuffer
|
|
|
|
@cython.boundscheck(False)
|
|
@cython.wraparound(False)
|
|
def read_numpy_array(buffer, np_type: str, unsigned long long num_rows):
|
|
dtype = np.dtype(np_type)
|
|
cdef sz = dtype.itemsize * num_rows
|
|
cdef char * source
|
|
if isinstance(buffer, ResponseBuffer):
|
|
source = (<ResponseBuffer>buffer).read_bytes_c(dtype.itemsize * num_rows)
|
|
return np.frombuffer(source[:sz], dtype, num_rows)
|
|
return np.frombuffer(buffer.read_bytes(sz), dtype, num_rows)
|