Sha256: d95fb054c27d4d0f7868043d3a6a61e30ff80c50a6fd41a61bf2f86a5ca507cd

Contents?: true

Size: 1.26 KB

Versions: 25

Compression:

Stored size: 1.26 KB

Contents

# Copyright 2014 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""A clone of the default copy.deepcopy that doesn't handle cyclic
structures or complex types except for dicts and lists. This is
because gyp copies so large structure that small copy overhead ends up
taking seconds in a project the size of Chromium."""


class Error(Exception):
    pass


__all__ = ["Error", "deepcopy"]


def deepcopy(x):
    """Deep copy operation on gyp objects such as strings, ints, dicts
  and lists. More than twice as fast as copy.deepcopy but much less
  generic."""

    try:
        return _deepcopy_dispatch[type(x)](x)
    except KeyError:
        raise Error(
            "Unsupported type %s for deepcopy. Use copy.deepcopy "
            + "or expand simple_copy support." % type(x)
        )


_deepcopy_dispatch = d = {}


def _deepcopy_atomic(x):
    return x


types = bool, float, int, str, type, type(None)

for x in types:
    d[x] = _deepcopy_atomic


def _deepcopy_list(x):
    return [deepcopy(a) for a in x]


d[list] = _deepcopy_list


def _deepcopy_dict(x):
    y = {}
    for key, value in x.items():
        y[deepcopy(key)] = deepcopy(value)
    return y


d[dict] = _deepcopy_dict

del d

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
immosquare-cleaner-0.1.52 node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py
immosquare-cleaner-0.1.51 node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py
immosquare-cleaner-0.1.50 node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py
immosquare-cleaner-0.1.49 node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py
immosquare-cleaner-0.1.48 node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py
immosquare-cleaner-0.1.47 node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py
immosquare-cleaner-0.1.46 node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py
immosquare-cleaner-0.1.45 node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py
immosquare-cleaner-0.1.44 node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py
immosquare-cleaner-0.1.43 node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py
immosquare-cleaner-0.1.42 node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py
immosquare-cleaner-0.1.41 node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py
immosquare-cleaner-0.1.40 node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py
immosquare-cleaner-0.1.39 node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py
immosquare-cleaner-0.1.38 node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py
immosquare-cleaner-0.1.32 node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py
immosquare-cleaner-0.1.31 node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py
immosquare-cleaner-0.1.30 node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py
immosquare-cleaner-0.1.29 node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py
immosquare-cleaner-0.1.28 node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py