Michael Van Biesbrouck added the comment: I am implementing a library that makes extensive use of delayed executions represented by functions. Copying objects both with and without shared state referenced by the functions is important. There is one entry point where I would expect functions to go. On the other hand, I can't prevent users from taking an instance method and wrapping it inside of a callable object that lacks an appropriate __deepcopy__ method (this would be a sensible thing to do, in fact).
I don't mind whether instance methods have shallow or deep copies as long as I can document the result. Neither invasive use of __deepcopy__ nor throwing an exception is suitable for my use. For reference, the exception is TypeError: instancemethod expected at least 2 arguments, got 0 Ideally, deepcopy() and pickle() would copy the internals of all function types and I could implement shared mutable state by using __deepcopy__ in a single class. I assume that this is unreasonable to implement. No matter the implementation, I think that there should be some way of running deepcopy() on all primitive types without throwing exceptions. I can see use cases where throwing exceptions for all types that can't be deeply copied would be useful and disabling __deepcopy__ might be important. __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue1515> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com