This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mlvanbie
Recipients gvanrossum, mlvanbie
Date 2007-12-20.00:47:18
SpamBayes Score 0.072032504
Marked as misclassified No
Message-id <1198111638.83.0.096935753144.issue1515@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2007-12-20 00:47:19mlvanbiesetspambayes_score: 0.0720325 -> 0.072032504
recipients: + mlvanbie, gvanrossum
2007-12-20 00:47:18mlvanbiesetspambayes_score: 0.0720325 -> 0.0720325
messageid: <1198111638.83.0.096935753144.issue1515@psf.upfronthosting.co.za>
2007-12-20 00:47:18mlvanbielinkissue1515 messages
2007-12-20 00:47:18mlvanbiecreate