← index #281PR #1098
Related · high · value 2.156
QUERY · ISSUE

deepcopy function references a non-existant variable

openby dhylandsopened 2018-05-23updated 2019-02-21

In copy.py: https://github.com/micropython/micropython-lib/blob/f20d89c6aad9443a696561ca2a01f7ef0c8fb302/copy/copy.py#L163 the deepcopy function references the variable dispatch_table, which isn't initialized.

2 comments
harryofskyrim · 2019-02-21

SO? The issue is still present, and it's really unpleasant

dhylands · 2019-02-21

I just reported this on pfalcon's repository which is the "official" source of this repository.
https://github.com/pfalcon/micropython-lib/issues/26

CANDIDATE · PULL REQUEST

copy: Provide top-level documentation.

openby agattiopened 2026-03-22updated 2026-03-23
docs

Summary

This PR 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.

This should clarify scenarios like the ones mentioned in #1090.

Generative AI

I did not use generative AI tools when creating this PR.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied