penguin-wwy commented on code in PR #1970:
URL: https://github.com/apache/fury/pull/1970#discussion_r1874499938
##########
python/pyfury/_serialization.pyx:
##########
@@ -2049,7 +2050,13 @@ cdef class MapSerializer(Serializer):
buffer.write_varint32(len(value))
cdef ClassInfo key_classinfo
cdef ClassInfo value_classinfo
- for k, v in value.items():
+ cdef int64_t key_addr, value_addr
+ cdef Py_ssize_t pos = 0
+ while PyDict_Next(value, &pos, <PyObject **>&key_addr, <PyObject
**>&value_addr) != 0:
+ k = int2obj(key_addr)
+ Py_INCREF(k)
Review Comment:
The references returned by `PyDict_Next` are borrowed; ideally, we wouldn't
need any reference counting operations. However, since Cython automatically
generates a `__Pyx_XDECREF` macro call for an object type variable at the end
of the scope and during an assignment, we must manually call `Py_INCREF` to
correct its reference count.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]