Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion cassandra/deserializers.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,15 @@ cpdef Deserializer find_deserializer(cqltype):


def obj_array(list objs):
"""Create a (Cython) array of objects given a list of objects"""
"""Create a (Cython) array of objects given a list of objects.

Returns the plain list for empty input since ``cython_array`` does
not support zero-length shapes. Callers that use
``cdef Deserializer[::1]`` typed memoryviews must guard against
empty input before assignment.
"""
if not objs:
return objs
cdef object[:] arr
cdef Py_ssize_t i
arr = cython_array(shape=(len(objs),), itemsize=sizeof(void *), format="O")
Expand Down
20 changes: 20 additions & 0 deletions cassandra/serializers.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright ScyllaDB, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


cdef class Serializer:
# The cqltypes._CassandraType corresponding to this serializer
cdef object cqltype

cpdef bytes serialize(self, object value, int protocol_version)
Loading
Loading