Re: [pypy-dev] serialize and deserialize objects in Pypy

2015-08-07 Thread Yicong Huang
In general, we don't need to parse or process Pypy object in C code, but only transfer the object from one Pypy enviroment to another Pypy enviroment. I am thinking could we have the alternavtive easier way to do this, like PyObject in Python? Could we get the address of the Pypy Object and the le

Re: [pypy-dev] serialize and deserialize objects in Pypy

2015-08-07 Thread Maciej Fijalkowski
yes, you need a serializer protocol, like JSON (or protobuf or anything). You generally need to express stuff in a way C can understand and read it in python On Fri, Aug 7, 2015 at 2:06 PM, Yicong Huang wrote: > The problem is we might need to support several kinds of collection objects: > list,

Re: [pypy-dev] serialize and deserialize objects in Pypy

2015-08-07 Thread Yicong Huang
The problem is we might need to support several kinds of collection objects: list, dict, tuple. In addition, we might not know what is exact type of objects stored in the collections. A list might store int, string, double. So it might involve a lot of work to write the python wrapper. Do you have

Re: [pypy-dev] serialize and deserialize objects in Pypy

2015-08-07 Thread Maciej Fijalkowski
you really can't convert it to the C stuff like that. You need to do: foo = ffi.new("int[]", 13) foo[0] = 12 foo[1] = 55 etc. You can write nice python wrapper around those things too, if the data is too bare bone. On Fri, Aug 7, 2015 at 1:09 PM, Yicong Huang wrote: > Hi Maciej, > > Could you

Re: [pypy-dev] serialize and deserialize objects in Pypy

2015-08-07 Thread Yicong Huang
Hi Maciej, Could you provide some details on how to use cffi buffers? (a simple demo code or documents) I tried the below code but it did not work. #python list x=[1,2,3,4] #intend to convert to c++ char*, but failed p=ffi.from_buffer(x) #intend to covert back to python list, but failed y=ffi.buf

Re: [pypy-dev] serialize and deserialize objects in Pypy

2015-08-07 Thread Carl Friedrich Bolz
Can't you use pickle or the json module? Cheers, Carl Friedrich On August 7, 2015 12:24:05 PM GMT+02:00, Maciej Fijalkowski wrote: >you can use cffi buffers (e.g. cffi char*) that you manipulate from >python using wrappers. They would behave (sort of) like python objects >and the wrapper cod

Re: [pypy-dev] serialize and deserialize objects in Pypy

2015-08-07 Thread Maciej Fijalkowski
you can use cffi buffers (e.g. cffi char*) that you manipulate from python using wrappers. They would behave (sort of) like python objects and the wrapper code is really not a performance penalty in most cases On Fri, Aug 7, 2015 at 12:19 PM, Yicong Huang wrote: > Hi, > > Are there any good metho

[pypy-dev] serialize and deserialize objects in Pypy

2015-08-07 Thread Yicong Huang
Hi, Are there any good methods to serialize Pypy object to C++ char* and deserialize to Pypy object from C++ char*? Our scenario like this: We have at least two C++ process running, and each process embeded Pypy to execute some functions. And we woule like to reuse Pypy object from one process t