@@ -45,9 +45,9 @@ from cassandra.util import is_little_endian
4545cdef inline void _check_float_range(double value) except * :
4646 """ Raise OverflowError for finite values outside float32 range.
4747
48- Matches the behavior of struct.pack('>f', value), which raises
49- struct.error for values that cannot be represented as a 32-bit
50- IEEE 754 float. inf, -inf, and nan pass through unchanged.
48+ Intentionally raises OverflowError (not struct.error) so callers
49+ can catch a single exception type. The accepted range matches
50+ struct.pack('>f', ...). inf, -inf, and nan pass through unchanged.
5151 """
5252 if not isinf(value) and not isnan(value):
5353 if value > < double > FLT_MAX or value < - < double > FLT_MAX:
@@ -58,9 +58,10 @@ cdef inline void _check_float_range(double value) except *:
5858cdef inline void _check_int32_range(object value) except * :
5959 """ Raise OverflowError for values outside the signed int32 range.
6060
61- Matches the behavior of struct.pack('>i', value), which raises
62- struct.error for values outside [-2147483648, 2147483647]. The check
63- must be done on the Python int *before* the C-level <int32_t> cast,
61+ Intentionally raises OverflowError (not struct.error) so callers
62+ can catch a single exception type. The accepted range matches
63+ struct.pack('>i', ...): [-2147483648, 2147483647]. The check must
64+ be done on the Python int *before* the C-level <int32_t> cast,
6465 which would silently truncate.
6566 """
6667 if value > 2147483647 or value < - 2147483648 :
@@ -215,7 +216,12 @@ cdef class SerVectorType(Serializer):
215216 return self ._serialize_generic(value, protocol_version)
216217
217218 cdef inline bytes _serialize_float(self , object values):
218- """ Serialize a list of floats into a contiguous big-endian buffer."""
219+ """ Serialize a list of floats into a contiguous big-endian buffer.
220+
221+ Uses ``values[i]`` (``__getitem__``) intentionally rather than
222+ iteration so Cython can emit a tight indexed loop with minimal
223+ Python overhead. Callers must pass a sequence (list, tuple, etc.).
224+ """
219225 cdef Py_ssize_t i
220226 cdef Py_ssize_t buf_size = self .vector_size * 4
221227 if buf_size == 0 :
@@ -244,7 +250,12 @@ cdef class SerVectorType(Serializer):
244250 return result
245251
246252 cdef inline bytes _serialize_double(self , object values):
247- """ Serialize a list of doubles into a contiguous big-endian buffer."""
253+ """ Serialize a list of doubles into a contiguous big-endian buffer.
254+
255+ Uses ``values[i]`` (``__getitem__``) intentionally rather than
256+ iteration so Cython can emit a tight indexed loop with minimal
257+ Python overhead. Callers must pass a sequence (list, tuple, etc.).
258+ """
248259 cdef Py_ssize_t i
249260 cdef Py_ssize_t buf_size = self .vector_size * 8
250261 if buf_size == 0 :
@@ -276,7 +287,12 @@ cdef class SerVectorType(Serializer):
276287 return result
277288
278289 cdef inline bytes _serialize_int32(self , object values):
279- """ Serialize a list of int32 values into a contiguous big-endian buffer."""
290+ """ Serialize a list of int32 values into a contiguous big-endian buffer.
291+
292+ Uses ``values[i]`` (``__getitem__``) intentionally rather than
293+ iteration so Cython can emit a tight indexed loop with minimal
294+ Python overhead. Callers must pass a sequence (list, tuple, etc.).
295+ """
280296 cdef Py_ssize_t i
281297 cdef Py_ssize_t buf_size = self .vector_size * 4
282298 if buf_size == 0 :
0 commit comments