Commit 347162f
committed
copy: Provide top-level documentation.
This commit adds documentation for the `copy` module, explaining why the
module may require some changes in the objects being copied to behave as
CPython.
Unlike CPython, MicroPython does not provide default implementations for
either `__reduce__` or `__reduce_ex__`, which are used by the copy module
as the fallback methods to create copies of non-trivial objects. These
methods aren't provided by default to minimise both the footprint of the
interpreter binary and the RAM taken by object instances.
Users who want simpler ways to allow object copies can implement
`__copy__` and `__deepcopy__` instead, as mentioned in CPython's
documentation for the `copy` module.
Arguably the lack of `__reduce__` and `__reduce_ex__` could also be
mentioned in MicroPython's own documentation as part of the differences
from CPython, but it doesn't hurt to mention more module-specific caveats
in here too. This should, in theory, keep user expectations in check
w.r.t. the behaviour of this specific module.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>1 parent 00efb6c commit 347162f
1 file changed
+24
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
0 commit comments