Skip to content

Commit d3f4bef

Browse files
committed
obj_parser: add boundscheck/wraparound optimizations, remove assert
Add @cython.boundscheck(False) and @cython.wraparound(False) decorators to both unpack_plain_row() and unpack_col_encrypted_row() in obj_parser.pyx, matching the pattern already used in numpy_parser.pyx. Remove the unnecessary 'assert desc.rowsize >= 0' runtime check from unpack_col_encrypted_row() since rowsize is always non-negative by construction from the protocol parser.
1 parent 4f3c748 commit d3f4bef

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

cassandra/obj_parser.pyx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ from cassandra.parsing cimport ParseDesc, ColumnParser, RowParser
2222
from cassandra.tuple cimport tuple_new, tuple_set
2323

2424
from cpython.bytes cimport PyBytes_AsStringAndSize
25+
cimport cython
2526

2627

2728
cdef class ListParser(ColumnParser):
@@ -65,9 +66,9 @@ cdef class TupleRowParser(RowParser):
6566
otherwsise use unpack_plain_row()
6667
"""
6768

69+
@cython.boundscheck(False)
70+
@cython.wraparound(False)
6871
cpdef unpack_col_encrypted_row(self, BytesIOReader reader, ParseDesc desc):
69-
assert desc.rowsize >= 0
70-
7172
cdef Buffer buf
7273
cdef Buffer newbuf
7374
cdef Py_ssize_t i, rowsize = desc.rowsize
@@ -101,6 +102,8 @@ cdef class TupleRowParser(RowParser):
101102

102103
return res
103104

105+
@cython.boundscheck(False)
106+
@cython.wraparound(False)
104107
cpdef unpack_plain_row(self, BytesIOReader reader, ParseDesc desc):
105108
cdef Buffer buf
106109
cdef Py_ssize_t i, rowsize = desc.rowsize

0 commit comments

Comments
 (0)