pypy and ctypes

Peter Chant pete at
Thu Nov 14 01:39:20 CET 2013

I'm looking to speed up some python code.  Replacing the python 
interpreter with pypy was impressive.  I noted that use of ctypes (in 
cython?), specifically declaring variables as below, was reported as 
giving a useful result:

cdef float myvar
cdef int i

under cython can provide a useful speed increase even if sections of 
code are not re-written in C.  Does this also work in PyPy?  From 
googling I keep getting pointed at ffi - but that seems to relate more 
to calling c-libraries rather than what I'm trying to do - seeing if 
there are any simple speed ups by declaring variables.

Or is it that - if I keep the code as simple as possible, PyPy is about 
as fast as you can get?


More information about the Python-list mailing list