-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
Hi,
I really love pypy and jitpy, but for my work, I need to pass complex arguments to pypy functions, not just ints or strings.
So my solution is to convert everything into strings with pickle. Of course it a very dirty hack, but my code still runs many,many times faster than python :-)
It would be great if jitpy could handle all this directly, with some kind of decorator. Unfortunately I don't have enough python/pypy expertise to customize jitpy.
Here is the code I use to send/receive pickled strings.
from jitpy import setup
setup('/opt/pypy-2.5.0-linux/bin')
from jitpy.wrapper import jittify
import pickle
from cffi import FFI
@jittify([str],str)
def func(_pypy_arg):
import pickle
from cffi import FFI
ffi = FFI()
args = pickle.loads( ffi.string(_pypy_arg) )
ret = "Processing "+str(args)+" and we're done..."
return ffi.new("char[]",pickle.dumps(ret))
ffi = FFI()
_ret = func( pickle.dumps(["go",4,"it !!!"]))
print pickle.loads( ffi.string(_ret) )Best regards,
Yann
Metadata
Metadata
Assignees
Labels
No labels