penguin-wwy commented on code in PR #2007:
URL: https://github.com/apache/fury/pull/2007#discussion_r1926454929


##########
python/pyfury/_util.pyx:
##########
@@ -572,12 +573,15 @@ cdef class Buffer:
         cdef uint64_t header = self.read_varuint64()
         cdef uint32_t size = header >> 2
         self.check_bound(self.reader_index, size)
+        if size == 0:
+            return ""
         cdef const char * buf = <const char *>(self.c_buffer.get().data() + 
self.reader_index)
         self.reader_index += size
         cdef uint32_t encoding = header & <uint32_t>0b11
         if encoding == 0:
             # PyUnicode_FromASCII
-            return PyUnicode_DecodeLatin1(buf, size, "strict")
+            return <unicode>Fury_PyUnicode_FromUCS1(buf, size)
+            # return PyUnicode_DecodeLatin1(buf, size, "strict")

Review Comment:
   Could you describe the testing method? The tests I wrote myself do not have 
this issue.
   ```python
   # integration_tests/cpython_benchmark/fury_benchmark.py
   STRING = 
"sjuveaibngurbzsivbrubiasb3r93284r92r1209130r0fa;2''j93r2nfln''[]\=-_+/,./!@$#%^&*()i9124u0hpq[jnzj0r9h034-2iu1058]"
   
   def micro_benchmark():
       runner.bench_func(
           "fury_string", fury_object, language, not args.no_ref, STRING
       )
       runner.bench_func(
           "fury_large_string", fury_object, language, not args.no_ref, STRING 
* 10000
       )
   ```
   Using PyUnicode_FromUCS1:
   fury_string: Mean +- std dev: 54.7 us +- 2.5 us
   fury_large_string: Mean +- std dev: 255 us +- 24 us
   
   Using Fury_PyUnicode_FromUCS1:
   fury_string: Mean +- std dev: 53.8 us +- 2.0 us
   fury_large_string: Mean +- std dev: 236 us +- 6 us



-- 
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]

Reply via email to