From 40f50cd7d74507109c45c59b8832290314dba212 2015-04-07 19:40:11 From: Min RK Date: 2015-04-07 19:40:11 Subject: [PATCH] remove use of utils.flatten use `list(chain.from_iterable))` which is equivalent --- diff --git a/ipython_kernel/serialize.py b/ipython_kernel/serialize.py index 1ad9f39..fd3d7ab 100644 --- a/ipython_kernel/serialize.py +++ b/ipython_kernel/serialize.py @@ -10,9 +10,9 @@ except: cPickle = None import pickle -# IPython imports +from itertools import chain + from IPython.utils.py3compat import PY3, buffer_to_bytes_py2 -from IPython.utils.data import flatten from ipython_kernel.pickleutil import ( can, uncan, can_sequence, uncan_sequence, CannedObject, istype, sequence_types, PICKLE_PROTOCOL, @@ -138,10 +138,12 @@ def pack_apply_message(f, args, kwargs, buffer_threshold=MAX_BYTES, item_thresho With length at least two + len(args) + len(kwargs) """ - arg_bufs = flatten(serialize_object(arg, buffer_threshold, item_threshold) for arg in args) + arg_bufs = list(chain.from_iterable( + serialize_object(arg, buffer_threshold, item_threshold) for arg in args)) kw_keys = sorted(kwargs.keys()) - kwarg_bufs = flatten(serialize_object(kwargs[key], buffer_threshold, item_threshold) for key in kw_keys) + kwarg_bufs = list(chain.from_iterable( + serialize_object(kwargs[key], buffer_threshold, item_threshold) for key in kw_keys)) info = dict(nargs=len(args), narg_bufs=len(arg_bufs), kw_keys=kw_keys) diff --git a/ipython_parallel/client/map.py b/ipython_parallel/client/map.py index 67b5b29..a3b908a 100644 --- a/ipython_parallel/client/map.py +++ b/ipython_parallel/client/map.py @@ -12,10 +12,7 @@ pieces to individual nodes in a cluster. from __future__ import division import sys -from itertools import islice - -from IPython.utils.data import flatten as utils_flatten - +from itertools import islice, chain numpy = None @@ -75,7 +72,7 @@ class Map(object): return numpy.concatenate(listOfPartitions) # Next try for Python sequence types if isinstance(testObject, (list, tuple)): - return utils_flatten(listOfPartitions) + return list(chain.from_iterable(listOfPartitions)) # If we have scalars, just return listOfPartitions return listOfPartitions @@ -125,5 +122,3 @@ def mappable(obj): dists = {'b':Map,'r':RoundRobinMap} - -