
    hs                     `    / S Qr SSKrSSKrSSKJr  SSKJr  S
S jrSS jr	SS jr
SS	 jr\rg))parent	referenceatparentschildren    N   )_proxy_helper)_locate_objectc                 L    Sn[        XX25      nUR                  5       nXPL a  gU$ )al  
>>> listiter = iter([4,5,6,7])
>>> obj = parent(listiter, list)
>>> obj == [4,5,6,7]  # actually 'is', but don't have handle any longer
True

NOTE: objtype can be a single type (e.g. int or list) or a tuple of types.

WARNING: if obj is a sequence (e.g. list), may produce unexpected results.
Parent finds *one* parent (e.g. the last member of the sequence).
    r   N)r   pop)objobjtypeignoredepthchainr   s         G/home/james-whalen/.local/lib/python3.13/site-packages/dill/pointers.pyr   r      s-     EC%0EYY[F}M    c                    ^ [         R                  nU4S jn[        US5      (       d  U4OUnS U 5       n[        XXB5      SSS2   nU$ )zFind the chain of referents for obj. Chain will end with obj.

objtype: an object type or tuple of types to search for
depth: search depth (e.g. depth=2 is 'grandparents')
ignore: an object or tuple of objects to ignore in the search
c                    > [        U T5      $ N
isinstancexr   s    r   <lambda>parents.<locals>.<lambda>-       *Q0r   __len__c              3   8   #    U  H  n[        U5      v   M     g 7fr   id.0r   s     r   	<genexpr>parents.<locals>.<genexpr>0        (#bgg   N)gcget_referentshasattr
find_chainr   r   r   r   	edge_func	predicater   s    `     r   r   r   %   sN       I0I%fi88fYfF((Fsy82>ELr   c                    ^ [         R                  nU4S jn[        US5      (       d  U4OUnS U 5       n[        XXBU5      nU$ )a  Find the chain of referrers for obj. Chain will start with obj.

objtype: an object type or tuple of types to search for
depth: search depth (e.g. depth=2 is 'grandchildren')
ignore: an object or tuple of objects to ignore in the search

NOTE: a common thing to ignore is all globals, 'ignore=(globals(),)'

NOTE: repeated calls may yield different results, as python stores
the last value in the special variable '_'; thus, it is often good
to execute something to replace '_' (e.g. >>> 1+1).
c                    > [        U T5      $ r   r   r   s    r   r   children.<locals>.<lambda>D   r   r   r   c              3   8   #    U  H  n[        U5      v   M     g 7fr   r    r"   s     r   r$   children.<locals>.<genexpr>G   r&   r'   )r)   get_referrersr+   r,   r-   s    `     r   r   r   6   sG       I0I%fi88fYfF((Fsy@ELr   c                 >   U /n[        U 5      S0n[        U 5      S 0n[        U5      nUR                  [        U5      5        UR                  [        U5      5        UR                  [        U5      5        UR                  [        U5      5        UR                  [        U5      5        UR                  [        [        R                  " 5       5      5        UR                  [        [        R                  " S5      5      5        [
        R                  " 5         U(       a  UR                  S5      n	U" U	5      (       aD  U	/n
U[        U	5         b0  U[        U	5         n	U
R                  U	5        U[        U	5         b  M0  U
$ U[        U	5         nX:  a|  U" U	5      nUR                  [        U5      5        U HT  n[        U5      U;   a  M  [        U5      U;  d  M%  US-   U[        U5      '   X[        U5      '   UR                  U5        MV     U(       a  M  U /$ )Nr   r   )	r!   setaddsys	_getframer)   collectr   append)r   r/   r.   	max_depthextra_ignorequeuer   r   r   targetr   tdepth	referrerssources                 r   r,   r,   S   s   EEWaLEgt_FF
JJr, 
JJr%y
JJr%y
JJr&z
JJr&z
JJr#--/"#
JJr#--"#$JJL
1VHEF$06
+V$ F$0 Lr&z"!&)IJJr)}%#f:'f:U*(.
E"V*%)/2f:&LL( $ %& 5Lr   ) )r   rD   )   rD   )__all__r)   r9   _dillr	   r   r
   r   r   r   r   r,   	refobjectrD   r   r   <module>rI      s4    ? 	 
 - '(": H 	r   