[pypy-svn] pypy jitypes2: add a performance hack
antocuni
commits-noreply at bitbucket.org
Sun Jan 16 18:34:55 CET 2011
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: jitypes2
Changeset: r40727:4b3cb1021874
Date: 2011-01-16 18:34 +0100
http://bitbucket.org/pypy/pypy/changeset/4b3cb1021874/
Log: add a performance hack
diff --git a/lib_pypy/_ctypes/function.py b/lib_pypy/_ctypes/function.py
--- a/lib_pypy/_ctypes/function.py
+++ b/lib_pypy/_ctypes/function.py
@@ -384,6 +384,12 @@
Convert from low-level repr of the result to the high-level python
one.
"""
+ # 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
More information about the Pypy-commit
mailing list