[pypy-issue] [issue968] very slow ctypes callbacks
Arman Bostani
tracker at bugs.pypy.org
Mon Dec 19 14:25:20 CET 2011
New submission from Arman Bostani <arman at twinsun.com>:
I've attached a simple Windows test case. Under pypy 1.7, this runs about 8 times
slower than CPython 2.7.2.
----------
files: testcb.py
messages: 3586
nosy: arman0, pypy-issue
priority: performance bug
release: 1.7
status: unread
title: very slow ctypes callbacks
________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue968>
________________________________________
-------------- next part --------------
from ctypes import *
import timeit
def py_cmp_func(a, b):
return a[0] - b[0]
CMPFUNC = CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))
cmp_func = CMPFUNC(py_cmp_func)
int_size = sizeof(c_int)
LEN = 5
IntArray5 = c_int * LEN
ia = IntArray5(5, 1, 7, 33, 99)
qsort = cdll.msvcrt.qsort
def f():
qsort(ia, LEN, int_size, cmp_func)
print timeit.repeat("f()", "from __main__ import f", number=100000)
More information about the pypy-issue
mailing list