Files
Joe SpadolaandGitHub fe7bb19b6d Reenable default Cython runtime path and reestablish C/Python parity (#679)
* reenable and fix driverc drift

* target ctypes directly

* linting

* update changelog

* pivot cython optimization

* update changelog
2026-03-11 16:21:34 -07:00

17 lines
540 B
Cython

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)