<commit_before># -*- coding: utf-8 -*-
import functools

from django.core.cache import cache as default_cache

try:
    from django.core.cache.backends.base import DEFAULT_TIMEOUT
except ImportError:  # Django < 1.6 compatibility
    DEFAULT_TIMEOUT = 300


from elephant.exceptions import CacheKeyFunctionNotDefined


class Elephant(object):
    """
    Elephant
    """
    def __init__(self):
        pass

    def memorize(
        self,
        cache=default_cache,
        cache_key=None,
        timeout=DEFAULT_TIMEOUT
    ):
        def memorize(f):
            @functools.wraps(f)
            def decorated_function(*args, **kwargs):
                if not callable(cache_key):
                    raise CacheKeyFunctionNotDefined()

                key = cache_key(f, *args, **kwargs)

                value = cache.get(key)

                if not value:
                    value = f(*args, **kwargs)
                    cache.set(key, value, timeout)
<commit_msg>convert memorize to static method<commit_after># -*- coding: utf-8 -*-
import functools

from django.core.cache import cache as default_cache

try:
    from django.core.cache.backends.base import DEFAULT_TIMEOUT
except ImportError:  # Django < 1.6 compatibility
    DEFAULT_TIMEOUT = 300


from elephant.exceptions import CacheKeyFunctionNotDefined


class Elephant(object):
    """
    Elephant
    """
    def __init__(self):
        pass

    @staticmethod
    def memorize(
        cache=default_cache,
        cache_key=None,
        timeout=DEFAULT_TIMEOUT
    ):
        def memorize(f):
            @functools.wraps(f)
            def decorated_function(*args, **kwargs):
                if not callable(cache_key):
                    raise CacheKeyFunctionNotDefined()

                key = cache_key(f, *args, **kwargs)

                value = cache.get(key)

                if not value:
                    value = f(*args, **kwargs)
                    cache.set(key, value, timeout)

{'fraction_non_alphanumeric': 0.0910010111223458, 'fraction_numerical': 0.006066734074823054, 'mean_word_length': 1.9849170437405732, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7279133', 'n_tokens_mistral': 573, 'n_tokens_neox': 542, 'n_words': 134}