Let's say I have a class with two methods, one will be decorated by a classmethod and the other one will not.
class MyClass():
def __init__(self):
self.my_string = 'Hello'
def test1(self):
return self.my_string
@classmethod
def test2(cls):
return cls().my_string
What is the difference between these two calls:
MyClass().test1()
MyClass.test2()
I checked the elapsed time of them and they differ a lot, so it got to be different somehow, but I can't understand why. Is there a preferable way of doing it? Thank you in advance.