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

    https://github.com/apache/spark/pull/5173#discussion_r27180143
  
    --- Diff: python/pyspark/cloudpickle.py ---
    @@ -40,164 +40,126 @@
     NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     """
    -
    +from __future__ import print_function
     
     import operator
     import os
    +import io
     import pickle
     import struct
     import sys
     import types
     from functools import partial
     import itertools
    -from copy_reg import _extension_registry, _inverted_registry, 
_extension_cache
    -import new
     import dis
     import traceback
    -import platform
    -
    -PyImp = platform.python_implementation()
    -
     
    -import logging
    -cloudLog = logging.getLogger("Cloud.Transport")
    +if sys.version < '3':
    +    from pickle import Pickler
    +    try:
    +        from cStringIO import StringIO
    +    except ImportError:
    +        from StringIO import StringIO
    +    PY3 = False
    +else:
    +    types.ClassType = type
    +    from pickle import _Pickler as Pickler
    +    from io import BytesIO as StringIO
    +    PY3 = True
     
     #relevant opcodes
    -STORE_GLOBAL = chr(dis.opname.index('STORE_GLOBAL'))
    -DELETE_GLOBAL = chr(dis.opname.index('DELETE_GLOBAL'))
    -LOAD_GLOBAL = chr(dis.opname.index('LOAD_GLOBAL'))
    +STORE_GLOBAL = dis.opname.index('STORE_GLOBAL')
    +DELETE_GLOBAL = dis.opname.index('DELETE_GLOBAL')
    +LOAD_GLOBAL = dis.opname.index('LOAD_GLOBAL')
     GLOBAL_OPS = [STORE_GLOBAL, DELETE_GLOBAL, LOAD_GLOBAL]
    +HAVE_ARGUMENT = dis.HAVE_ARGUMENT
    +EXTENDED_ARG = dis.EXTENDED_ARG
     
    -HAVE_ARGUMENT = chr(dis.HAVE_ARGUMENT)
    -EXTENDED_ARG = chr(dis.EXTENDED_ARG)
    -
    -if PyImp == "PyPy":
    -    # register builtin type in `new`
    -    new.method = types.MethodType
    -
    -try:
    -    from cStringIO import StringIO
    -except ImportError:
    -    from StringIO import StringIO
     
    -# These helper functions were copied from PiCloud's util module.
     def islambda(func):
    -    return getattr(func,'func_name') == '<lambda>'
    +    return getattr(func,'__name__') == '<lambda>'
     
    -def xrange_params(xrangeobj):
    -    """Returns a 3 element tuple describing the xrange start, step, and len
    -    respectively
     
    -    Note: Only guarentees that elements of xrange are the same. parameters 
may
    -    be different.
    -    e.g. xrange(1,1) is interpretted as xrange(0,0); both behave the same
    -    though w/ iteration
    -    """
    -
    -    xrange_len = len(xrangeobj)
    -    if not xrange_len: #empty
    -        return (0,1,0)
    -    start = xrangeobj[0]
    -    if xrange_len == 1: #one element
    -        return start, 1, 1
    -    return (start, xrangeobj[1] - xrangeobj[0], xrange_len)
    -
    -#debug variables intended for developer use:
    -printSerialization = False
    -printMemoization = False
    +_BUILTIN_TYPE_NAMES = {}
    +for k, v in types.__dict__.items():
    --- End diff --
    
    This is used for pickle builtin types.


---
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