Skip to content

Instantly share code, notes, and snippets.

View koirikivi's full-sized avatar

Rainer Koirikivi koirikivi

View GitHub Profile
@koirikivi
koirikivi / bench_cached_property_decorator.py
Last active September 20, 2023 15:51 — forked from smithdc1/bench_cached_property_decorator.py
Benchmark of Django and Python's cached_property decorators (with IO and multithreading)
import pyperf
import time
from concurrent.futures import ThreadPoolExecutor
from django.utils.functional import cached_property as dj_cached_property
from functools import cached_property as py_cached_property
# Most web requests have some IO, like database access. Simulate with sleeping
SLEEP_TIME = 0.01