Sounds quite simple, but I couldn’t found a solution anywhere. I need to copy a built‑in function object (I’m not talking about the function code but the object that represent it) such as :
id(func)≠id(func_copy)
Where func and func_copy share the same object type.
However if (for example) I do :
import copy
new_type=copy.copy(oct)
then id(new_type)
and id(oct)
are still equal.
I also couldn’t found how to modify oct
attributes or append attribute to it (it would have resulted in changing the idea).
Update
This question isn’t a duplicate because copy python function and built‑in function isn’t the same problem : you can’t copy built‑in function objects with the same methods for python function objects and vice versa.
So none of the solutions on How can I make a deepcopy of a function in Python? can work here.
Please vote to re‑open