Python Forum
Python Classes or Functions for large scale application ?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Classes or Functions for large scale application ?
#5
My code looks like this.

from wq import x
from ew import y
from fa import z
from oh import a
from la import b
from ha import c

class Sample: 
    def __init__(self):
       self.x = X()
       self.y = Y()
       self.z = Z()
       self.a = A()
       self.b = B()
       self.c = C()

   def calculate_something(self):
       self.answer = self.a.getValue() + self.b.getAnswer() + self.c.getOptions() + self.x.getVehichles()

   ....
Likewise I have to import all required classes from other sub directories and create an instance of them within my Sample class __init__. Here I had to create objects 6 objects of 6 classes. Then SampleTwo class has similar set of dependencies and it will also import around 4 classes and create instance of that within SampleTwo class's __init__ method.

So when the project grows larger, more number of objects will be created. Is that okay? Considering the garbage collection, memory usage of the application, etc?
Or is there any better way to do that?
Reply


Messages In This Thread
RE: Python Classes or Functions for large scale application ? - by Vithulan - Oct-23-2017, 01:57 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Problems writing a large text file in python Vilius 4 979 Dec-21-2024, 09:20 AM
Last Post: Pedroski55
  How to change a tkinter label with scale and how to save that new value for later? bkeith 3 1,903 Jun-28-2024, 01:35 AM
Last Post: deanhystad
  Python Classes rob101 4 1,470 Feb-05-2024, 06:51 PM
Last Post: rob101
  Understanding Python classes PythonNewbee 3 2,142 Nov-10-2022, 11:07 PM
Last Post: deanhystad
Sad Python classes PythonNewbee 4 2,079 Nov-09-2022, 01:19 PM
Last Post: deanhystad
  How to properly scale text in postscript conversion to pdf? philipbergwerf 3 2,121 Nov-07-2022, 01:30 PM
Last Post: philipbergwerf
  Python running only in application Mawixy 2 1,793 Apr-19-2022, 11:38 AM
Last Post: Mawixy
  KeyError: 0 when trying to dedupe and match records at scale Catalytic 1 4,133 Apr-07-2022, 06:34 PM
Last Post: deanhystad
  Inheritance vs Instantiation for Python classes mr_byte31 7 5,214 Oct-14-2021, 12:58 PM
Last Post: mr_byte31
  breaking a large program into functions, not acting as expected Zane217 9 4,470 Sep-18-2021, 12:37 AM
Last Post: Zane217

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020