0

Let's say I have 10 really random functions in a python file. I could keep them like that, or I could bundle them into a class.

Just for example:

def one:
   pass

def two:
   pass

#more 8 functions

If I wanted to bundle them into a class would it be more efficient or it doesn't make a difference?

class R:
   def one:
      pass

   #more 9 functions

So, which option is memory wise better?

Esh200111
  • 71
  • 1
  • 8
  • 2
    Putting memory aside, why would you want to put them in a class just because? Classes have specific purposes and shouldn't be forced to use... If your functions don't ***need*** to be in a class (i.e. use some invariant state of an encapsulating object), I don't see any reason to put them inside one – Tomerikoo Jan 20 '21 at 13:38
  • 1
    Also, check https://stackoverflow.com/questions/18202818/classes-vs-functions – buran Jan 20 '21 at 13:40

0 Answers0