Revert to intrinsic memcpy instead of inline
PYTHON-450 intrinsic was 25% faster in benchmarks
This commit is contained in:
@@ -18,6 +18,7 @@ import six
|
||||
|
||||
from libc.stdint cimport (int8_t, int16_t, int32_t, int64_t,
|
||||
uint8_t, uint16_t, uint32_t, uint64_t)
|
||||
from libc.string cimport memcpy
|
||||
from cassandra.buffer cimport Buffer, buf_read, to_bytes
|
||||
|
||||
cdef bint is_little_endian
|
||||
@@ -25,15 +26,6 @@ from cassandra.util import is_little_endian
|
||||
|
||||
cdef bint PY3 = six.PY3
|
||||
|
||||
cdef inline void memcopy(char *dst, char *src, Py_ssize_t size):
|
||||
"""
|
||||
Our own simple memcopy which can be inlined. This is useful because our data types
|
||||
are only a few bytes.
|
||||
"""
|
||||
cdef Py_ssize_t i
|
||||
for i in range(size):
|
||||
dst[i] = src[i]
|
||||
|
||||
ctypedef fused num_t:
|
||||
int64_t
|
||||
int32_t
|
||||
@@ -59,7 +51,7 @@ cdef inline num_t unpack_num(Buffer *buf, num_t *dummy=NULL): # dummy pointer be
|
||||
for i in range(sizeof(num_t)):
|
||||
out[sizeof(num_t) - i - 1] = src[i]
|
||||
else:
|
||||
memcopy(out, src, sizeof(num_t))
|
||||
memcpy(out, src, sizeof(num_t))
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ cdef inline int unpack_row(
|
||||
Py_INCREF(val)
|
||||
(<PyObject **> arr.buf_ptr)[0] = <PyObject *> val
|
||||
else:
|
||||
memcopy(<char *> arr.buf_ptr, buf.ptr, buf.size)
|
||||
memcpy(<char *> arr.buf_ptr, buf.ptr, buf.size)
|
||||
|
||||
# Update the pointer into the array for the next time
|
||||
arrays[i].buf_ptr += arr.stride
|
||||
|
||||
Reference in New Issue
Block a user