Пример #1
0
def maybe_dill_dumps(o):
    """Pickle using cPickle or the Dill pickler as a fallback."""
    # We need to use the dill pickler for objects of certain custom classes,
    # including, for example, ones that contain lambdas.
    try:
        return pickle.dumps(o, pickle.HIGHEST_PROTOCOL)
    except Exception:  # pylint: disable=broad-except
        return dill.dumps(o)
Пример #2
0
def maybe_dill_dumps(o):
  """Pickle using cPickle or the Dill pickler as a fallback."""
  # We need to use the dill pickler for objects of certain custom classes,
  # including, for example, ones that contain lambdas.
  try:
    return pickle.dumps(o, pickle.HIGHEST_PROTOCOL)
  except Exception:  # pylint: disable=broad-except
    return dill.dumps(o)