Danny Yoo wrote:

> On Thu, Jul 2, 2015 at 12:30 PM, Jim Mooney Py3.4.3winXP
> <cybervigila...@gmail.com> wrote:
>> When an instance uses a class method, does it actually use the method
>> that is in the class object's memory space, or is the method copied to
>> the instance?

> Unsure.  How would it be observable?

[snip implementation details]

My understanding of the question is less involved. I'd suggest:

Create a class Foo with a method bar(), say, instantiate it, replace foo in 
the class and then invoke foo in the previously created instance. 

If the old method is executed the instance must keep a copy, if the new 
method is executed there is probably no copy.

>>> class Foo:
...     def bar(self): print("original bar")
... 
>>> foo = Foo()
>>> def modified_bar(self):
...     print("modified bar")
... 
>>> Foo.bar = modified_bar
>>> foo.bar()
modified bar

Conclusion: no copy.

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to