Make a deep copy of list and dict objects.

    Intentionally do not copy attributes.  This is to discard CommentedMap and
    CommentedSeq metadata which is very expensive with regular copy.deepcopy.
967765
def deepcopy_strip(item):  # type: (Any) -> Any
    

    if isinstance(item, MutableMapping):
        return {k: deepcopy_strip(v) for k, v in iteritems(item)}
    if isinstance(item, MutableSequence):
        return [deepcopy_strip(k) for k in item]
    return item
793024
def copy(self, only=None):
        '''
        
        '''
        if only is None:
            return Mesh(self)
        else:
            import copy
            m = Mesh()
            for a in only:
                setattr(m, a, copy.deepcopy(getattr(self, a)))
            return m
1053235
def copy(self, deep=False, name=None):
        
        if deep:
            other = deepcopy(self)
        else:
            other = copy(self)

        if hasattr(self, 'name'):
            other.name = get_default(name, self.name + '_copy')

        return other
536185
function deepCopy(srcObj) {
      var tmpObj;
      if (isArr(srcObj)) {
        tmpObj = [];
        for (var i = 0; i < srcObj.length; i++) {
          tmpObj.push(deepCopy(srcObj[i]));
        }
      } else if (isObj(srcObj)) {
        tmpObj = {};
        for (var key in srcObj) {
          if (has(srcObj, key)) tmpObj[key] = deepCopy(srcObj[key]);
        }
      } else {
        tmpObj = srcObj;
      }
      return tmpObj;
    }
174885
def revise(self, data, ignore_none=True):
        
        if not isinstance(data, dict):
            raise TypeError("`data` has to be a dict!")

        if ignore_none:
            for key, value in data.items():
                if value is not None:
                    setattr(self, key, deepcopy(value))
        else:
            for key, value in data.items():
                setattr(self, key, deepcopy(value))

        return self
137808
def dedupe_list_of_dicts(ld):
    
    def _freeze(o):
        """Recursively freezes a dict into an hashable object.

        Adapted from http://stackoverflow.com/a/21614155/374865.
        """
        if isinstance(o, dict):
            return frozenset((k, _freeze(v)) for k, v in six.iteritems(o))
        elif isinstance(o, (list, tuple)):
            return tuple(_freeze(v) for v in o)
        else:
            return o

    result = []
    seen = set()

    for d in ld:
        f = _freeze(d)
        if f not in seen:
            result.append(d)
            seen.add(f)

    return result
1099416
public static final Object deepCopy(Object source, final KunderaMetadata kunderaMetadata)
    {
        Map<Object, Object> copiedObjectMap = new HashMap<Object, Object>();

        Object target = deepCopyUsingMetadata(source, copiedObjectMap, kunderaMetadata);

        copiedObjectMap.clear();
        copiedObjectMap = null;

        return target;
    }
586354
def deepcopy(obj):
    
    if isinstance(obj, JavaObject):
        wrapped = True
        jobject = obj.jobject
    else:
        wrapped = False
        jobject = obj
    try:
        serialized = javabridge.make_instance("weka/core/SerializedObject", "(Ljava/lang/Object;)V", jobject)
        jcopy = javabridge.call(serialized, "getObject", "()Ljava/lang/Object;")
        if wrapped:
            jcopy = obj.__class__(jobject=jcopy)
        return jcopy
    except JavaException as e:
        print("Failed to create copy of " + classes.get_classname(obj) + ": " + str(e))
        return None
1114166
function deepCopy(obj) {
			var ret = {}, key, val;
			for (key in obj) {
				if (obj.hasOwnProperty(key)) {
					val = obj[key];
					if (typeof val === 'object' && val !== null) {
						ret[key] = deepCopy(val);
					} else {
						ret[key] = val;
					}
				}
			}
			return ret;
		}
237767
def copy(self):
        
        c = copy.copy(self)
        c._fieldDict = c._fieldDict.copy()
        return c
524263
def copy(self):
		
		out = self._from_iterable(None)
		out._dict = self._dict.copy()
		out._size = self._size
		return out
1098128
function deepCopy(obj)
{
	var ret, key;
	var marker = '__deepCopy';

	if (obj && obj[marker])
		throw (new Error('attempted deep copy of cyclic object'));

	if (obj && obj.constructor == Object) {
		ret = {};
		obj[marker] = true;

		for (key in obj) {
			if (key == marker)
				continue;

			ret[key] = deepCopy(obj[key]);
		}

		delete (obj[marker]);
		return (ret);
	}

	if (obj && obj.constructor == Array) {
		ret = [];
		obj[marker] = true;

		for (key = 0; key < obj.length; key++)
			ret.push(deepCopy(obj[key]));

		delete (obj[marker]);
		return (ret);
	}

	/*
	 * It must be a primitive type -- just return it.
	 */
	return (obj);
}
1358597
def copy(self, name=None):
        
        return Struct.copy(self, deep=True, name=name)
663803
def deepcopy(data):
    """"""
    try:
        return pickle.loads(pickle.dumps(data))
    except TypeError:
        return copy.deepcopy(data)
1323619
def copy(self):
        
        connection = self.connection
        del self.connection
        copied_query = deepcopy(self)
        copied_query.connection = connection
        self.connection = connection
        return copied_query
231155
def to_dict(self, copy=False):
        
        new_dict = {}
        for attr, value in self:
            if copy:
                value = deepcopy(value)
            new_dict[attr] = value

        return new_dict
833676
def fast_deepcopy(obj):
    
    with BytesIO() as buf:
        pickle.dump(obj, buf)
        buf.seek(0)
        obj_new = pickle.load(buf)
    return obj_new