[Tutor] method conflict?

Jim Mooney Py3.4.3winXP cybervigilante at gmail.com
Fri Jul 3 02:39:12 CEST 2015


Okay, it appears the method in a class has its own ID, but all
instantiations of that method have identical IDs. But what happens if we
have a huge number of instantiations trying to access the identical method
at the same time?

class MyClass:
    def setdata(self, data):
        self.data = data
    def getdata(self):
        print(self.data)


>>> MyClass.setdata
<function MyClass.setdata at 0x026CACD8>
>>> id(MyClass.setdata)
40676568
>>> f = MyClass()
>>> g = MyClass()
>>> id(f.setdata)
43576616
>>> id(g.setdata)
43576616
>>> d = MyClass()
>>> id(d.setdata)
43576616


-- 
Jim


More information about the Tutor mailing list