Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/3264#discussion_r20373577
  
    --- Diff: python/pyspark/context.py ---
    @@ -289,12 +289,31 @@ def stop(self):
     
         def parallelize(self, c, numSlices=None):
             """
    -        Distribute a local Python collection to form an RDD.
    -
    -        >>> sc.parallelize(range(5), 5).glom().collect()
    -        [[0], [1], [2], [3], [4]]
    -        """
    -        numSlices = numSlices or self.defaultParallelism
    +        Distribute a local Python collection to form an RDD. Use xrange if
    +        the input represents a range for performance.
    +
    +        >>> sc.parallelize([0, 2, 3, 4, 6], 5).glom().collect()
    +        [[0], [2], [3], [4], [6]]
    +        >>> sc.parallelize(xrange(0, 6, 2), 5).glom().collect()
    +        [[], [0], [], [2], [4]]
    +        """
    +        numSlices = int(numSlices) if numSlices is not None else 
self.defaultParallelism
    +        if isinstance(c, xrange):
    +            size = len(c)
    +            if size == 0:
    +                return self.parallelize([], numSlices)
    +            step = c[1] - c[0] if size > 1 else 1
    +            c1 = xrange(c[0], c[0] + (size + 1) * step, step)
    +
    --- End diff --
    
    Yes, this is better!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to