[IPython-User] IPython parallel and namedtuple
John Reid
j.reid@mail.cryst.bbk.ac...
Tue Feb 19 03:50:23 CST 2013
On 18/02/13 20:28, MinRK wrote:
>
>
>
>
> Sorry about this. I've made a pull request
> <https://github.com/ipython/ipython/pull/2951> against master that
> should fix it.
>
> A patch for stable IPython is a bit messy. You would have to
> monkeypatch IPython.zmq.serialize.serialize_object/unserialize_object to
> handle namedtuples specially.
>
> The other (probably better) options in the meantime are:
>
> use a trivial class instead of namedtuple:
>
> class Result(object):
> def __init__(self, **kwargs):
> for key, value in kwargs.items():
> setattr(self, key, value)
>
> r = Result(pid=os.getpid(), duration=time.time() - start)
>
> or do the namedtuple wrapping on the Client side:
>
> def task():
> ...
> return os.getpid(), time.time() - start
>
> amr = view.map_async(task)
> for tup in amr:
> r = helper.Result(tup)
>
>
> Neither of which is awesome, but thanks for the report, the fix should
> be in master shortly.
Thanks for that. If you're interested my question on the python language
newsgroup sparked some discussion about whether namedtuples should share
construction syntax with tuples:
http://comments.gmane.org/gmane.comp.python.general/726849
More information about the IPython-User
mailing list