o
    KDiT	                     @   s   d Z ddlZddlmZmZ dZdZeedrejZ	nzddl
Z
W n ey-   ej Y nw e
jZ	G dd deZee	d	d ZdS )
a  :mod:`methodtools` --- functools for methods
===============================================

Expand functools features to methods, classmethods, staticmethods and even for
(unofficial) hybrid methods.

For now, methodtools only provides :func:`methodtools.lru_cache`.

Use methodtools module instead of functools module. Than it will work as you
expected - cache for each bound method.

.. code-block:: python

    from methodtools import lru_cache

    class A(object):

        # cached method. the storage lifetime follows `self` object
        @lru_cache()
        def cached_method(self, args):
            ...

        # cached classmethod. the storage lifetime follows `A` class
        @lru_cache()  # the order is important!
        @classmethod  # always lru_cache on top of classmethod
        def cached_classmethod(self, args):
            ...

        # cached staticmethod. the storage lifetime follows `A` class
        @lru_cache()  # the order is important!
        @staticmethod  # always lru_cache on top of staticmethod
        def cached_staticmethod(self, args):
            ...

    @lru_cache()  # just same as functools.lru_cache
    def cached_function():
        ...
    N)WireWireRopez0.4.7)	lru_cacher   c                       s,   e Zd Z fddZdd Zdd Z  ZS )_LruCacheWirec                    sV   t t| j|g|R i | |j\}}t|i || j}|| _|j| _|j| _d S N)	superr   __init___args_functools_lru_cache__func____call__cache_clear
cache_info)selfropeargskwargslru_args
lru_kwargswrapper	__class__ D/var/www/Datamplify/venv/lib/python3.10/site-packages/methodtools.pyr   =   s   
z_LruCacheWire.__init__c                 O   s   | j |i |S r   r   )r   r   r   r   r   r   r   F   s   z_LruCacheWire.__call__c                 C   s   |   S r   r   )r   r   r   r   _on_propertyJ   s   z_LruCacheWire._on_property)__name__
__module____qualname__r   r   r   __classcell__r   r   r   r   r   ;   s    	r   c                  O   s   t td| |fdS )NT)wraps	rope_args)r   r   )r   r   r   r   r   r   N   s   )__doc__	functoolswireroper   r   __version____all__hasattrr   r
   functools32ImportErrorr   r    r   r   r   r   <module>   s     '

