
    bi                        d Z ddlZddlZddlZddlZ	 ddlZdZ e	edd       Z
i Zi Z eeeeeeef      Z ed eej(                  ej*                  ej,                  efD              Zd Zedededededededej6                  dej8                  dej:                  di
fd	Zdd
Zd Z ddZ!d Z"e#Z#d Z$e$e_#         e%ed      re`& eej(                  jO                               D ]
  Z( ee(         e         y# e$ r dZY w xY w)z@
Module to show if an object has changed since it was memorised
    NTFgetrefcountc                      y)Nr    )xs    F/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/dill/__diff.py<lambda>r      s        c              #   2   K   | ]  }t        |        y wN)id).0is     r   	<genexpr>r   !   s      %!1 %s   c                 r    t        |       t        v st        |       t         u r	| t        v ryt        | dd      S )zQ
    Gets all the attributes of an object though its __dict__ or return None
    N__dict__)typebuiltins_typesgetattr)objs    r   	get_attrsr   %   s5     CyN"
s)t
~ 53
D))r	   c                    	 | j                   }t        }||v r!||   r || d      r| j	                         S | S yt
        rR|t        j                  t        j                  j                  j                  fv r| j                  r| j                  r| S g S  || d      rM || d      rD || d      r; ||d      r2 ||d      r) ||d      r d||<    || d      r| j	                         S | S d||<   y# t        $ r t        |       }Y w xY w)z9
    Gets all the items in a sequence or return None
    copy__contains____iter____len__TFN)	__class__AttributeErrorr   hasattrr   	HAS_NUMPYnumpyndarraymacoreMaskedConstantshapesize)r   cacheo_typehsattrs       r   get_seqr*   /   s    F=c6"xxz!J  
v%--1M1M!NN99JI	^	$Z)@#y!fV^&D&*%&*Cf#v88:
f-  cs   C- -DDc                    t        |       }|t        v r|r|t        v ryt         t        |       }|d}n"t	        fd|j                         D              }t        |       }|d}nSt        |d      r#t	        fd|j                         D              }n$t        |d      sd}n|D cg c]
  } |       }}||ft        |<   | t        |<   t        }|)|j                         D 	
cg c]  \  }	}
 ||
       c}
}	 |jt        |d      r2|j                         D 	cg c]  \  }	} ||	       ||      f c}}	 yt        |d      r|D cg c]
  } ||       c} y ||       yyc c}w c c}
}	w c c}}	w c c}w )z
    Adds an object to the memo, and recursively adds all the objects
    attributes, and if it is a container, its items. Use force=True to update
    an object already in the memo. Updating is not recursively done.
    Nc              3   8   K   | ]  \  }}| |      f  y wr   r   r   keyvalueid_s      r   r   zmemorise.<locals>.<genexpr>_   s     EZS%SZ(Es   itemsc              3   D   K   | ]  \  }} |       |      f  y wr   r   r-   s      r   r   zmemorise.<locals>.<genexpr>e   s"     H
Us3xE
+Hs    r   )
r   memo	dont_memor   dictr1   r*   r   	id_to_objmemorise)r   forceobj_idgattrs_idsseq_idr   memr.   r/   itemr0   s               @r   r7   r7   Q   s`    WF~ev':
C#AyE1779EEAy	G	HaggiHHQ	""#$Q#a&$$V#DLIf
C}&'ggi0
UU0}1gggi)d #hD	" ) q)$'()tT)a&  % 	1) *s   *E-*E2!E8E>c                      t         j                  t        j                  t        }}} t	        t         j                               D cg c]   \  }} ||      dk  r | |       ||      f" c}} y c c}}w )N   )r6   popr3   r   listr1   )itopmpsrcr0   r   s        r   release_gonerG   {   sY    MM488[c"D*.y/@*A hc3C1 3iC  s   %A1c                    |rdt         j                  v rt         `|i }t        |       }||v r|rt	        ||         S ||   S |t
        v ri dg||<   |ry||   S |t        vr|ryt        dt        |       z         i df||<   t        }t        }t        |       i }ngt        |   d   }|j                  }	t        fd|D              }j                         D ](  \  }
} ||       |	|
d      k7  s |||dd      s$|||
<   * t        |       }d}|t        |d      rt        |   d	   }t!        |      t!        |      k7  rd}nt        | d
      rV|j                  }	|j                         D ]6  \  }
} ||       |	 ||
            k7  s ||
|dd      s |||dd      s4d} n0 n.t#        ||      D ]  \  }} ||      |k7  s |||dd      sd} n ||f||<   |r|xs |S ||fS )aG  
    Check an object against the memo. Returns a list in the form
    (attribute changes, container changed). Attribute changes is a dict of
    attribute name to attribute value. container changed is a boolean.
    If simple is true, just returns a boolean. None for either item means
    that it has not been checked yet
    _NFTzObject not memorised r   c              3   0   K   | ]  }|vs|d f  y wr   r   )r   r.   attrss     r   r   z whats_changed.<locals>.<genexpr>   s     Kc#U:JDzKs   		r      r1   )builtinsr   rI   r   anyr4   r3   RuntimeErrorstrwhats_changedr   getr5   r1   r*   r   lenzip)r   seensimplefirstr9   chngdr0   changed	obj_attrsobj_getr.   or1   seq_diffobj_seqr?   r   jrK   s                     @r   rQ   rQ      s:    (###
<DWF~tF|$$F| E{VF|	t	6SABB;DLE
C cNE}LO	--KYKKkkm 	!FC1vd++uQdE/J 	!
 CLEHy 9v,q/J#g,&HS'"kkG"[[] 	Tt9C 11CtU3D$e4#H E7+ 1q6Q;%4u"=#H H$DL"("Hr	   c                  "    d|d<   t        | i |S )NTrV   )rQ   )argskwdss     r   has_changedrc      s    DN$'$''r	   c                     t        t        j                  j                               }t	        | i |}t        t        j                  j                               j                  |      }|D ]  }t        t        j                  |            |S )zn
    Replaces the default __import__, to allow a module to be memorised
    before the user can change it
    )setsysmoduleskeys
__import__
differencer7   )ra   rb   beforemodafterms         r   _impro      sp    
 !!#$F
d
#d
#C  "#..v6E !Q !Jr	   rI   )F)NFT))__doc__rM   osrf   typesnumpy.mar    r   ImportErrorr   r   r3   r6   re   rP   rC   r5   	frozensetintr   rg   path_importer_cacheenvironr4   r   tupler   
ModuleTypeFunctionTypeBuiltinFunctionTyper*   r7   rG   rQ   rc   ri   ro   r   rI   valuesrl   r   r	   r   <module>r~      s\    	 
 I
 c=*5
 
	c4sIs;< %ckk33J3JZZ $ % %	* UIudD#tdE4u((%1C1CU115: D'TK\( 

  
8S
 ""$% CSM m  Is   C= =DD