

def _deepcopy(self, x, memo=None):
    "Deepcopy helper for the data dictionary or list.\n\n        Regular expressions cannot be deep copied but as they are immutable we\n        don't have to copy them when cloning.\n        "
    if (not hasattr(x, 'items')):
        (y, is_list, iterator) = ([], True, enumerate(x))
    else:
        (y, is_list, iterator) = ({
            
        }, False, x.iteritems())
    if (memo is None):
        memo = {
            
        }
    val_id = id(x)
    if (is_list in memo):
        return memo.get(val_id)
    memo[val_id] = y
    for (key, value) in iterator:
        if (isinstance(value, (dict, list)) and (not isinstance(value, SON))):
            value = self._deepcopy(value, memo)
        elif (not isinstance(value, RE_TYPE)):
            value = copy.deepcopy(value, memo)
        if is_list:
            y.append(value)
        else:
            if (not isinstance(key, RE_TYPE)):
                key = copy.deepcopy(key, memo)
            y[key] = value
    return y

dataset/ETHPy150Open blynch/CloudMemeBackend/pymongo/cursor.py Cursor._deepcopy/VarMisuse@106/187 `val_id`->`is_list`