<commit_before>
import threading
import saga.utils.singleton

# ------------------------------------------------------------------------------
#
class ObjectCache (object) :

    """ This is a singleton object caching class -- it maintains a reference
    counted registry of existing objects."""

    __metaclass__ = saga.utils.singleton.Singleton
    _lock         = threading.RLock ()

    # --------------------------------------------------------------------------
    #
    def __init__ (self) :
        """
        Make sure the object cache dict is initialized, exactly once.
        """

        with self._lock :
            self._cache = {}


    # --------------------------------------------------------------------------
    #
    def get_obj (self, oid, creator, *args, **kwargs) :
        """
        For a given object id, attempt to retrieve an existing object.  If that
        object exists, increase the reference counter, as there is now one more
        user for that object.  
        
        If that object does not exist, call the given creator, then register and
        return the object thusly created.
        """

        with self._lock :

            oid = str(oid)

            if  not oid in self._cache :

                obj = creator (*args,  **kwargs)
<commit_msg>use lambdas for object creation<commit_after>
import threading
import saga.utils.singleton

# ------------------------------------------------------------------------------
#
class ObjectCache (object) :

    """ This is a singleton object caching class -- it maintains a reference
    counted registry of existing objects."""

    __metaclass__ = saga.utils.singleton.Singleton
    _lock         = threading.RLock ()

    # --------------------------------------------------------------------------
    #
    def __init__ (self) :
        """
        Make sure the object cache dict is initialized, exactly once.
        """

        with self._lock :
            self._cache = {}


    # --------------------------------------------------------------------------
    #
    def get_obj (self, oid, creator) :
        """
        For a given object id, attempt to retrieve an existing object.  If that
        object exists, increase the reference counter, as there is now one more
        user for that object.  
        
        If that object does not exist, call the given creator, then register and
        return the object thusly created.
        """

        with self._lock :

            oid = str(oid)

            if  not oid in self._cache :

                obj = creator ()

{'fraction_non_alphanumeric': 0.23717701504049363, 'fraction_numerical': 0.0, 'mean_word_length': 1.1491300745650372, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6116048', 'n_tokens_mistral': 591, 'n_tokens_neox': 557, 'n_words': 222}