remove @staticmethod decorators

There might have been a time when calling a static method was faster
than a regular method, but that is no longer the case. According to
micro-benchmarks, it is 70% slower in CPython 3.13 and it also makes
executing the code of a class definition slower.
This commit is contained in:
Mike Fährmann
2025-06-12 22:13:46 +02:00
parent 8b6bc54e95
commit 811b665e33
68 changed files with 139 additions and 252 deletions

View File

@@ -62,12 +62,10 @@ class ComparePP(PostProcessor):
def _compare(self, f1, f2):
return self._compare_size(f1, f2) and self._compare_content(f1, f2)
@staticmethod
def _compare_size(f1, f2):
def _compare_size(self, f1, f2):
return os.stat(f1).st_size == os.stat(f2).st_size
@staticmethod
def _compare_content(f1, f2):
def _compare_content(self, f1, f2):
size = 16384
with open(f1, "rb") as fp1, open(f2, "rb") as fp2:
while True:

View File

@@ -268,8 +268,7 @@ class MetadataPP(PostProcessor):
if not private:
return util.filter_dict
@staticmethod
def _make_encoder(options, indent=None):
def _make_encoder(self, options, indent=None):
return json.JSONEncoder(
ensure_ascii=options.get("ascii", False),
sort_keys=options.get("sort", False),

View File

@@ -425,15 +425,13 @@ class UgoiraPP(PostProcessor):
return (None, None)
@staticmethod
def _delay_gcd(frames):
def _delay_gcd(self, frames):
result = frames[0]["delay"]
for f in frames:
result = gcd(result, f["delay"])
return result
@staticmethod
def _delay_is_uniform(frames):
def _delay_is_uniform(self, frames):
delay = frames[0]["delay"]
for f in frames:
if f["delay"] != delay: