From 8d40a2cd10e96f34b190b0584012b4ec513d4128 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Mon, 7 Aug 2023 21:03:23 +0000 Subject: [PATCH] refactor: change methods not using its bound instance to staticmethods The method doesn't use its bound instance. Decorate this method with `@staticmethod` decorator, so that Python does not have to instantiate a bound method for every instance of this class thereby saving memory and computation. Read more about staticmethods [here](https://docs.python.org/3/library/functions.html#staticmethod). --- Calculator/time_calulator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Calculator/time_calulator.py b/Calculator/time_calulator.py index 90fcab6..37ecdf0 100644 --- a/Calculator/time_calulator.py +++ b/Calculator/time_calulator.py @@ -2,7 +2,8 @@ class TimeCalculator: def __init__(self, hours=0, minutes=0, seconds=0): self.total_seconds = self.to_seconds(hours, minutes, seconds) - def to_seconds(self, hours, minutes, seconds): + @staticmethod + def to_seconds(hours, minutes, seconds): return hours * 3600 + minutes * 60 + seconds def add_time(self, hours=0, minutes=0, seconds=0):