Antonio Cuni committed 4b3cb10

add a performance hack

  • Participants
  • Parent commits 81b4de5
  • Branches jitypes2

Comments (0)

Files changed (1)

File lib_pypy/_ctypes/

         Convert from low-level repr of the result to the high-level python
+        # hack for performance: if restype is a "simple" primitive type, don't
+        # allocate the buffer because it's going to be thrown away immediately
+        from _ctypes.primitive import _SimpleCData
+        if restype.__bases__[0] is _SimpleCData and not restype._is_pointer_like():
+            return result
+        #
         shape = restype._ffishape
         if is_struct_shape(shape):
             buf = result