
    !h	                        % S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	J
r
  SSKJr  \	(       a  SSKJr  SS	KJr  \" S
5      r\" \5      rS\S'    " S S5      r\4SS jjrSS jrSS jrSS jrg
)a  This module provides some functions and classes to record and report
references to live object instances.

If you want live objects for a particular class to be tracked, you only have to
subclass from object_ref (instead of object).

About performance: This library has a minimal performance impact when enabled,
and no performance penalty at all when disabled (as object_ref becomes just an
alias to object in that case).
    )annotations)defaultdict)
itemgetter)time)TYPE_CHECKINGAny)WeakKeyDictionary)Iterable)SelfNz$defaultdict[type, WeakKeyDictionary]	live_refsc                  &    \ rS rSrSrSrSS jrSrg)
object_ref   z<Inherit from this class to a keep a record of live instances c                X    [         R                  U 5      n[        5       [        U    U'   U$ )N)object__new__r   r   )clsargskwargsobjs       \/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/scrapy/utils/trackref.pyr   object_ref.__new__$   s%    nnS!"f	#s
    N)r   r   r   r   returnr   )__name__
__module____qualname____firstlineno____doc__	__slots__r   __static_attributes__r   r   r   r   r      s    FIr   r   c           
     ,   Sn[        5       n[        [        R                  5       S S9 Hf  u  p4U(       d  M  [	        X05      (       a  M   [        UR                  5       5      nXR                  S S[        U5      S S[        X%-
  5       S3-  nMh     U$ )	z2Return a tabular representation of tracked objectszLive References

c                     U S   R                   $ )Nr   )r   )xs    r   <lambda>"format_live_refs.<locals>.<lambda>/   s    admmr   keyz<30 6z   oldest: zs ago
)
r   sortedr   items
issubclassminvaluesr   lenint)ignoresnowr   wdictoldests         r   format_live_refsr8   +   s    A
&CY__.4KL
c""U\\^$	S!3u:a.C<M;NgVV M Hr   c                 ,    [        [        U 0 UD65        g)zPrint tracked objectsN)printr8   )akws     r   print_live_refsr=   9   s    	
A
$
$%r   c                    [         R                  5        HD  u  pUR                  U :X  d  M  U(       d    g[        UR                  5       [	        S5      S9S   s  $    g)z/Get the oldest object for a specific class name   r(   r   N)r   r-   r   r/   r   
class_namer   r6   s      r   
get_oldestrB   >   sM    oo'
<<:% u{{}*Q-8;;	 (
 r   c                    [         R                  5        H'  u  pUR                  U :X  d  M  UR                  5       s  $    / $ )z<Iterate over all objects of the same class by its class name)r   r-   r   keysr@   s      r   iter_allrE   H   s4    oo'
<<:%::< ( Ir   )r3   r   r   str)r;   r   r<   r   r   None)rA   rF   r   r   )rA   rF   r   zIterable[Any])r    
__future__r   collectionsr   operatorr   r   typingr   r   weakrefr	   collections.abcr
   typing_extensionsr   typeNoneTyper   __annotations__r   r8   r=   rB   rE   r   r   r   <module>rR      sh   	 # #   % %( ' :2=>O2P	/ P  $, &
r   