{
  "id": "copy",
  "name": "copy",
  "description": "",
  "version": "3.3.5",
  "author": "",
  "license": "MIT",
  "tags": [
    "python-stdlib"
  ],
  "status": "HUMAN_REVIEWED",
  "official": true,
  "source": "https://github.com/micropython/micropython-lib/tree/master/python-stdlib/copy",
  "updatedAt": "2025-11-19T03:55:17.660Z",
  "page": "https://checkmim.com/packages/copy",
  "createdAt": "2025-05-27T04:19:19.510Z",
  "install": {
    "mpremote": "mpremote mip install copy",
    "mip": "import mip; mip.install(\"copy\")"
  },
  "readme": "# copy\n\nNon-trivial objects (eg. classes) instantiated by CPython are usually able to\nbe copied by methods of this module without any modification, as the copying\nmechanism makes use of two functions (`__reduce__` and `__reduce_ex__`) that\nare added to instances by CPython itself.\n\nMicroPython does not do that, to keep the interpreter's binary size down and to\nlimit the RAM footprint of object instances.  This means that this module is\nnot able to copy non-trivial objects without specific changes to your code.\n\nThe `copy` module methods look for two methods being available in an instance:\n[`__copy__`](https://docs.python.org/3/library/copy.html#object.__copy__) and\n[`__deepcopy__`](https://docs.python.org/3/library/copy.html#object.__deepcopy__),\nand the module will call those functions to create a copy (either shallow or\ndeep) of the object.  Implementing either of those methods in a class will\nallow instances of that class to be copied both in MicroPython and CPython,\nkeeping code compatible with the two interpreters.\n\n`__reduce__` and `__reduce_ex__` will be used in MicroPython if a class\nprovides them, but unless you're also planning to use object pickling,\n`__copy__` and `__deepcopy__` are the simplest way to make sure things work in\nall cases.\n"
}