o
    Ö]¼j¯  ã                   @   sB   d Z dZG dd„ deƒZefZdd„ Zdd„ Zdd	„ Zd
d„ ZdS )z'Key functions for memoizing decorators.)ÚhashkeyÚ	methodkeyÚtypedkeyÚtypedmethodkeyc                   @   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 u r|| ƒ | _ }|S ©N)Ú_HashedTuple__hashvalue)ÚselfÚhashÚ	hashvalue© r   úR/home/dinkstrade/pdmp-scanner/venv/lib/python3.10/site-packages/cachetools/keys.pyÚ__hash__   s   z_HashedTuple.__hash__c                 C   s   t || |ƒƒS r   ©r   ©r   ÚotherÚaddr   r   r   Ú__add__   ó   z_HashedTuple.__add__c                 C   s   t ||| ƒƒS r   r   r   r   r   r   Ú__radd__   r   z_HashedTuple.__radd__c                 C   s   i S r   r   )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 )z8Return a cache key for the specified hashable arguments.)r   Ú_kwmarkr   ÚsortedÚitems)ÚargsÚkwargsr   r   r   r   %   s   r   c                 O   ó   t |i |¤ŽS )z/Return a cache key for use with cached methods.)r   ©r   r   r   r   r   r   r   .   ó   r   c                  O   s^   |rt t| ¡ ƒƒ}t| t | ƒ}|t dd„ |D ƒƒ7 }nt| ƒ}|t dd„ | D ƒƒ7 }|S )z>Return a typed cache key for the specified hashable arguments.c                 s   s   � | ]	\}}t |ƒV  qd S r   ©Útype)Ú.0Ú_Úvr   r   r   Ú	<genexpr>9   s   € ztypedkey.<locals>.<genexpr>c                 s   s   � | ]}t |ƒV  qd S r   r#   )r%   r'   r   r   r   r(   <   s   € )r   r   r   r   r   )r   r   Úsorted_kwargsÚkeyr   r   r   r   3   s   r   c                 O   r    )z5Return a typed cache key for use with cached methods.)r   r!   r   r   r   r   @   r"   r   N)	r   Ú__all__r   r   r   r   r   r   r   r   r   r   r   Ú<module>   s    	