سؤال

In a programming framework, what happens to unused classes that exist but is never called upon?

Will they have no impact on the performance since they're never called?

Or will they sit there, do nothing and cause performance downgrade?

هل كانت مفيدة؟

المحلول

They will only take up a bit more memory space and add a bit to the overhead initializing time for defining the class. They will not affect runtime speeds.

Example:

import time
t1 = time.time()

class A:
    def __init__(self):
        pass

>>> print time.time() - t1
0.00399994850159

VS

import time
t1 = time.time()

>>> print time.time() - t1
0.000999927520752
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top