Re: [zeromq-dev] Passing a python object (PyZMQ)

2015-06-09 Thread Arnaud Loonstra
On 06/08/2015 08:10 PM, MinRK wrote: On Mon, Jun 8, 2015 at 11:00 AM, Arnaud Loonstra arn...@sphaero.org mailto:arn...@sphaero.org wrote: A python dictionary is not thread safe, AFAIK. So if multiple producers(threads) write to the dictionary you'll run into trouble. Depends what

Re: [zeromq-dev] Passing a python object (PyZMQ)

2015-06-08 Thread MinRK
On Mon, Jun 8, 2015 at 11:00 AM, Arnaud Loonstra arn...@sphaero.org wrote: A python dictionary is not thread safe, AFAIK. So if multiple producers(threads) write to the dictionary you'll run into trouble. Depends what you mean. All of Python is threadsafe, thanks to the GIL. Since object IDs

Re: [zeromq-dev] Passing a python object (PyZMQ)

2015-06-08 Thread Arnaud Loonstra
A python dictionary is not thread safe, AFAIK. So if multiple producers(threads) write to the dictionary you'll run into trouble. Rg, Arnaud On June 8, 2015 6:05:08 PM GMT+02:00, Min RK benjami...@gmail.com wrote: On Jun 8, 2015, at 01:35, Arnaud Loonstra arn...@sphaero.org wrote: On

Re: [zeromq-dev] Passing a python object (PyZMQ)

2015-06-08 Thread Arnaud Loonstra
On 06/06/2015 01:52 AM, MinRK wrote: Without using ctypes, you could pass the objects through a namespace: |# shared namespace ns = {} # sender ns[id(obj)] = obj pipe_out.send(struct.pack(b'Q',1)) # receiver id_bytes = pipe_in.recv() obj_id = struct.unpack(b'Q', id_bytes)[0] obj =

Re: [zeromq-dev] Passing a python object (PyZMQ)

2015-06-08 Thread Min RK
On Jun 8, 2015, at 01:35, Arnaud Loonstra arn...@sphaero.org wrote: On 06/06/2015 01:52 AM, MinRK wrote: Without using ctypes, you could pass the objects through a namespace: |# shared namespace ns = {} # sender ns[id(obj)] = obj pipe_out.send(struct.pack(b'Q',1)) # receiver

Re: [zeromq-dev] Passing a python object (PyZMQ)

2015-06-05 Thread MinRK
Without using ctypes, you could pass the objects through a namespace: # shared namespace ns = {} # sender ns[id(obj)] = obj pipe_out.send(struct.pack(b'Q', 1)) # receiver id_bytes = pipe_in.recv() obj_id = struct.unpack(b'Q', id_bytes)[0] obj = ns.pop(obj_id) The ctypes cast approach doesn’t

Re: [zeromq-dev] Passing a python object (PyZMQ)

2015-06-04 Thread Arnaud Loonstra
On 2015-06-03 17:25, Arnaud Loonstra wrote: On 2015-06-03 10:20, Arnaud Loonstra wrote: I read here: http://zeromq.github.io/pyzmq/serialization.html PyZMQ being able to pass an object without copying it. I guess this holds only for the serialised copy of the data..? In theory the object can

[zeromq-dev] Passing a python object (PyZMQ)

2015-06-03 Thread Arnaud Loonstra
I read here: http://zeromq.github.io/pyzmq/serialization.html PyZMQ being able to pass an object without copying it. I guess this holds only for the serialised copy of the data..? In theory the object can be passed as a reference thus preventing a copy. Suppose I have an image as a python

Re: [zeromq-dev] Passing a python object (PyZMQ)

2015-06-03 Thread Arnaud Loonstra
On 2015-06-03 10:20, Arnaud Loonstra wrote: I read here: http://zeromq.github.io/pyzmq/serialization.html PyZMQ being able to pass an object without copying it. I guess this holds only for the serialised copy of the data..? In theory the object can be passed as a reference thus preventing a