
    7Th)                         S r SSKrSSKrSSKrSSKrSSKrSSKrSSKr\R                  r	 " S S\
5      r " S S\
5      r " S S\	5      r " S	 S
\5      rSS jrg)zb
Fast cryptographic hash of Python objects, with a special case for fast
hashing of numpy arrays.
    Nc                       \ rS rSrSrS rSrg)_ConsistentSet   zTClass used to ensure the hash of Sets is preserved
whatever the order of its items.
c                      [        U5      U l        g ! [        [        R                  4 a    [        S U 5       5      U l         g f = f)Nc              3   8   #    U  H  n[        U5      v   M     g 7fNhash).0es     F/var/www/auris/envauris/lib/python3.13/site-packages/joblib/hashing.py	<genexpr>*_ConsistentSet.__init__.<locals>.<genexpr>%   s     $ClT!WWls   )sorted	_sequence	TypeErrordecimalInvalidOperation)selfset_sequences     r   __init___ConsistentSet.__init__   sF    		E
 $L1DN7334 	E $$Cl$CDDN	Es    1AA)r   N__name__
__module____qualname____firstlineno____doc__r   __static_attributes__     r   r   r      s    Er!   r   c                       \ rS rSrSrS rSrg)_MyHash(   z5Class used to hash objects that won't normally picklec                     Xl         g r   args)r   r'   s     r   r   _MyHash.__init__+   s    	r!   r&   Nr   r    r!   r   r#   r#   (   s
    ?r!   r#   c                   &   \ rS rSrSrSS jrSS jrS rS rS\	R                  4S jr\R                  R                  5       r\\\" \5      '   \\\" \5      '   \\\" \5      '   \\\" \R&                  5      '   S	 rS
 r\\\" \" 5       5      '   Srg)Hasher/   zA subclass of pickler, to do cryptographic hashing, rather than
pickling. This is used to produce a unique hash of the given
Python object that is not necessarily cryptographically secure.
c                     [         R                  " 5       U l        Sn[        R	                  X R                  US9  [
        R                  " USS9U l        g )N   )protocolF)usedforsecurity)ioBytesIOstreamPicklerr   hashlibnew_hash)r   	hash_namer.   s      r   r   Hasher.__init__5   s?    jjl {{X>[[EB
r!   c                 J    U R                  U5        U R                  R                  5       nU R                  R                  U5        U(       a  U R                  R                  5       $ g ! [        R                   a$  nU=R                  SU< SU< 34-  sl        e S nAff = f)NzPicklingError while hashing z: )	dumppicklePicklingErrorr'   r2   getvaluer6   update	hexdigest)r   objreturn_digestr   dumpss        r   r
   Hasher.hash>   s    	IIcN $$&

% ::''))  ## 	FFsAFHHF	s   A* *B">BB"c                    [        U[        R                  [        0 R                  5      45      (       a  [        US5      (       a  UR                  R                  nOUR                  nUR                  n[        U5      [        [        5      L a  [        X#R                  5      nO1Uc  [        X#5      nO"UR                  R                  n[        X#U5      n[        R                  X5        g )N__func__)
isinstancetypes
MethodTypetypepophasattrrE   r   __self__r;   r#   	__class__r3   save)r   r@   	func_nameinstclss        r   rN   Hasher.saveI   s    cE,,d266l;<< sJ''LL11	LL	<<DDzT&\)i7i.ll,,is3Tr!   c                 f    [        U[        [        45      (       a  g [        R	                  X5        g r   )rF   bytesstrr3   memoize)r   r@   s     r   rV   Hasher.memoize\   s$    
 cE3<(("r!   Nc                 \   [        X#S9nUS	  [        R                  " X40 UD6  g ! [        R                   aq    [        R                  " X40 UD6  [        USS 5      nUS:X  aD  UnUc  UR                  n[        R                  U   n[        Xv5      (       d  [        XvU5         g  g  g f = f)N)namepackrZ   r   __main__)dictr3   save_globalr;   r<   getattrr   sysmodulesrK   setattr)r   r@   rY   rZ   kwargsmodulemy_namemods           r   r]   Hasher.save_globalg   s     4+6N	/4V4## 	/4V4S,5F#?!llGkk&)s,, C#. - $	/s   & A>B+*B+c           
           [         R                  " U [        [        U5      5      /UQ76   g ! [         a4    [         R                  " U [        [        S U 5       5      5      /UQ76    g f = f)Nc              3   @   #    U  H  u  p[        U5      U4v   M     g 7fr   r	   )r   kvs      r   r   )Hasher._batch_setitems.<locals>.<genexpr>   s     !A54147A,5s   )r3   _batch_setitemsiterr   r   )r   itemsr'   s      r   rl   Hasher._batch_setitems   sc    	
 ##D$ve}*=EE 	 ##d6!A5!AABEI	s   *- ;A+*A+c                 B    [         R                  U [        U5      5        g r   )r3   rN   r   )r   	set_itemss     r   save_setHasher.save_set   s    T>)45r!   )r6   r2   )md5)T)r   r   r   r   r   r   r
   rN   rV   structrZ   r]   r3   dispatchcopyrI   lenobjectr;   r:   rl   rr   setr   r    r!   r   r*   r*   /   s    
C	* &# %)v{{ /* $$&H%HT#Y(HT&\)HT']"-HT&++6 %HT#%[r!   r*   c                   (    \ rS rSrSrSS jrS rSrg)NumpyHasher   z1Special case the hasher for when numpy is loaded.c                     X l         [        R                  XS9  SSKnX0l        [        US5      (       a  UR                  U l        g[        U l        g)z
Parameters
----------
hash_name: string
    The hash algorithm to be used
coerce_mmap: boolean
    Make no difference between np.memmap and np.ndarray
    objects.
r7   r   N	getbuffer)	coerce_mmapr*   r   numpynprK   r   
_getbuffer
memoryview)r   r7   r   r   s       r   r   NumpyHasher.__init__   s?     '22{## llDO(DOr!   c                 2   [        XR                  R                  5      (       Ga_  UR                  R                  (       GdC  UR
                  S:X  a  UR                  5       nOVUR                  R                  (       a  UnO8UR                  R                  (       a  UR                  nOUR                  5       nU R                  R                  U R                  UR                  U R                  R                  5      5      5        U R                   (       a;  [        XR                  R"                  5      (       a  U R                  R                  nOUR$                  nUSUR                  UR
                  UR&                  44nO~[        XR                  R                  5      (       aZ  U R                  R                  SR)                  S5      5        U R                  R                  [*        R,                  " U5      5        g[.        R1                  X5        g)zSubclass the save method, to hash ndarray subclass, rather
than pickling them. Off course, this is a total abuse of
the Pickler class.
r    HASHED_HASHED_DTYPEzutf-8N)rF   r   ndarraydtype	hasobjectshapeflattenflagsc_contiguousf_contiguousTr6   r>   r   viewuint8r   memmaprM   stridesencoder;   rB   r*   rN   )r   r@   obj_c_contiguousklasss       r   rN   NumpyHasher.save   s\   
 c77??++CII4G4G4G yyB $';;= ''#& ''#&55 
 $';;=  JJdoo.>.C.CDGGMM.RST
 JsGGNN$C$C 
 8SYY		3;;GHCWW]]++  JJo44W=>JJfll3/0Dr!   )r   r   r   Nrt   F)r   r   r   r   r   r   rN   r   r    r!   r   r|   r|      s    ;)*>r!   r|   c                     SnX;  a  [        SR                  X15      5      eS[        R                  ;   a
  [	        XS9nO	[        US9nUR                  U 5      $ )a%  Quick calculation of a hash to identify uniquely Python objects
containing numpy arrays.

Parameters
----------
hash_name: 'md5' or 'sha1'
    Hashing algorithm used. sha1 is supposedly safer, but md5 is
    faster.
coerce_mmap: boolean
    Make no difference between np.memmap and np.ndarray
)rt   sha1zAValid options for 'hash_name' are {}. Got hash_name={!r} instead.r   )r7   r   r   )
ValueErrorformatr_   r`   r|   r*   r
   )r@   r7   r   valid_hash_nameshashers        r   r
   r
      s_     '(OVV 
 	

 #++yJ),;;sr!   r   )r   r   r4   r0   r;   ru   r_   rG   _Picklerr3   ry   r   r#   r*   r|   r
   r    r!   r   <module>r      sg      	   
 
//EV E&f l%W l%^V& Vrr!   