Skip to content

Commit 5d5f1b1

Browse files
committed
Revert to intrinsic memcpy instead of inline
PYTHON-450 intrinsic was 25% faster in benchmarks
1 parent 827f460 commit 5d5f1b1

2 files changed

Lines changed: 3 additions & 11 deletions

File tree

cassandra/cython_marshal.pyx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,14 @@ import six
1818

1919
from libc.stdint cimport (int8_t, int16_t, int32_t, int64_t,
2020
uint8_t, uint16_t, uint32_t, uint64_t)
21+
from libc.string cimport memcpy
2122
from cassandra.buffer cimport Buffer, buf_read, to_bytes
2223

2324
cdef bint is_little_endian
2425
from cassandra.util import is_little_endian
2526

2627
cdef bint PY3 = six.PY3
2728

28-
cdef inline void memcopy(char *dst, char *src, Py_ssize_t size):
29-
"""
30-
Our own simple memcopy which can be inlined. This is useful because our data types
31-
are only a few bytes.
32-
"""
33-
cdef Py_ssize_t i
34-
for i in range(size):
35-
dst[i] = src[i]
36-
3729
ctypedef fused num_t:
3830
int64_t
3931
int32_t
@@ -59,7 +51,7 @@ cdef inline num_t unpack_num(Buffer *buf, num_t *dummy=NULL): # dummy pointer be
5951
for i in range(sizeof(num_t)):
6052
out[sizeof(num_t) - i - 1] = src[i]
6153
else:
62-
memcopy(out, src, sizeof(num_t))
54+
memcpy(out, src, sizeof(num_t))
6355

6456
return ret
6557

cassandra/numpy_parser.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ cdef inline int unpack_row(
153153
Py_INCREF(val)
154154
(<PyObject **> arr.buf_ptr)[0] = <PyObject *> val
155155
else:
156-
memcopy(<char *> arr.buf_ptr, buf.ptr, buf.size)
156+
memcpy(<char *> arr.buf_ptr, buf.ptr, buf.size)
157157

158158
# Update the pointer into the array for the next time
159159
arrays[i].buf_ptr += arr.stride

0 commit comments

Comments
 (0)