I am setting up a python class and I have 2 ways to go about it:
- Create a class and all methods as class methods. When calling the methods on my main block, it would be cls.methodName()
e.g.
class demoClass():
@classmethod
methodA(cls):
print('Method A')
Calling from main
demoClass.methodA()
demoClass.methodA()
demoClass.methodA()
- Create a class and all methods are object methods and require an instance of the class to call them.
e.g.
class demoClass():
methodA(self):
print('Method A')
Calling from main
demoObj = demoClass()
demoObj.methodA()
demoObj.methodA()
demoObj.methodA()
I want know which way would be better. I am more inclined towards using Object level methods because this class will be used across a lot of parts of the main code for different scenarios and require different setup for each scenario hence setting up the objects specific to each use case would make sense
My major point of concern is performance and memory usage Between the 2 approaches, which would be better in terms of just performance and memory usage (disregard the use case)?