Reputation: 5387
How does one define copy
and deepcopy
methods for a Python type defined in a C extension?
Looking at the documentation, there doesn't appear to be a tp_
slot for these methods.
Upvotes: 1
Views: 250
Reputation: 280993
There's no slot. You just define the same methods you'd define in Python, but in C. (Typically, that means implementing __reduce__
and getting the default __reduce__
-based copy.copy
and copy.deepcopy
behavior, but you can also implement __copy__
and __deepcopy__
if you want.)
Upvotes: 3