B
    ­»ˆdM  ã               @   s:   d Z dZG dd„ deƒZefZdd„ Zdd„ Zdd	„ Zd
S )z'Key functions for memoizing decorators.)ÚhashkeyÚ	methodkeyÚtypedkeyc               @   sF   e Zd ZdZdZejfdd„Zejfdd„Zejfdd„Zd	d
„ Z	dS )Ú_HashedTuplezðA tuple that ensures that hash() will be called no more than once
    per element, since cache decorators will hash the key multiple
    times on a cache miss.  See also _HashedSeq in the standard
    library functools implementation.

    Nc             C   s    | j }|d kr|| ƒ | _ }|S )N)Ú_HashedTuple__hashvalue)ÚselfÚhashÚ	hashvalue© r	   úA/var/www/html/venv/lib/python3.7/site-packages/cachetools/keys.pyÚ__hash__   s    z_HashedTuple.__hash__c             C   s   t || |ƒƒS )N)r   )r   ÚotherÚaddr	   r	   r
   Ú__add__   s    z_HashedTuple.__add__c             C   s   t ||| ƒƒS )N)r   )r   r   r   r	   r	   r
   Ú__radd__   s    z_HashedTuple.__radd__c             C   s   i S )Nr	   )r   r	   r	   r
   Ú__getstate__   s    z_HashedTuple.__getstate__)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Útupler   r   r   r   r	   r	   r	   r
   r      s   r   c              O   s*   |rt | tt| ¡ ƒtƒ ƒS t | ƒS dS )z8Return a cache key for the specified hashable arguments.N)r   ÚsumÚsortedÚitemsÚ_kwmark)ÚargsÚkwargsr	   r	   r
   r   %   s    r   c             O   s
   t ||ŽS )z/Return a cache key for use with cached methods.)r   )r   r   r   r	   r	   r
   r   .   s    r   c              O   sB   t | |Ž}|tdd„ | D ƒƒ7 }|tdd„ t| ¡ ƒD ƒƒ7 }|S )z>Return a typed cache key for the specified hashable arguments.c             s   s   | ]}t |ƒV  qd S )N)Útype)Ú.0Úvr	   r	   r
   ú	<genexpr>7   s    ztypedkey.<locals>.<genexpr>c             s   s   | ]\}}t |ƒV  qd S )N)r   )r   Ú_r   r	   r	   r
   r   8   s    )r   r   r   r   )r   r   Úkeyr	   r	   r
   r   3   s    
r   N)r   Ú__all__r   r   r   r   r   r   r	   r	   r	   r
   Ú<module>   s   	