o w[e#@s>ddlmZddlmZdgZGdddZGdddZdS)ref) GenericAliasWeakSetc@s$eZdZddZddZddZdS)_IterationGuardcCst||_dSN)r weakcontainer)selfrr "/usr/lib/python3.10/_weakrefset.py__init__sz_IterationGuard.__init__cCs |}|dur|j||Sr)r _iteratingadd)r wr r r __enter__s z_IterationGuard.__enter__cCs8|}|dur|j}|||s|dSdSdSr)rr remove_commit_removals)r etbrsr r r __exit__s  z_IterationGuard.__exit__N)__name__ __module__ __qualname__r rrr r r r r s rc@s&eZdZd@ddZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZddZddZddZeZd d!Zd"d#Zd$d%ZeZd&d'Zd(d)Zd*d+ZeZd,d-Zd.d/ZeZd0d1Zd2d3Zd4d5Z e Z!d6d7Z"d8d9Z#d:d;Z$e$Z%dd?Z'e(e)Z*dS)ArNcCsFt|_t|fdd}||_g|_t|_|dur!||dSdS)NcSs8|}|dur|jr|j|dS|j|dSdSr)r _pending_removalsappenddatadiscard)itemselfrefr r r r _remove's z!WeakSet.__init__.._remove)setrrr!rr update)r rr!r r r r %szWeakSet.__init__cCs<|jj}|jj} z|}Wn tyYdSw||q r)rpoprr IndexError)r r$rrr r r r5s  zWeakSet._commit_removalsccsPt||jD] }|}|dur|Vq WddS1s!wYdSr)rrr itemrefrr r r __iter__?s  "zWeakSet.__iter__cCst|jt|jSr)lenrrr r r r __len__HzWeakSet.__len__cCs,zt|}Wn tyYdSw||jvS)NF)r TypeErrorr)r rwrr r r __contains__Ks    zWeakSet.__contains__cCs|jt|ft|ddfS)N__dict__) __class__listgetattrr*r r r __reduce__Rs  zWeakSet.__reduce__cCs&|jr||jt||jdSr)rrrrrr!r rr r r rVsz WeakSet.addcCs|jr||jdSr)rrrclearr*r r r r6[sz WeakSet.clearcCs ||Srr1r*r r r copy` z WeakSet.copycCsL|jr| z|j}Wn tytddw|}|dur%|Sq)NTzpop from empty WeakSet)rrrr$KeyErrorr&r r r r$cs  z WeakSet.popcC"|jr||jt|dSr)rrrrrr5r r r rozWeakSet.removecCr;r)rrrrrr5r r r rtr<zWeakSet.discardcCs&|jr||D]}||q dSr)rrr)r otherelementr r r r#ys  zWeakSet.updatecCs|||Sr)r#r r=r r r __ior__s zWeakSet.__ior__cC|}|||Sr)r8difference_updater r=newsetr r r difference zWeakSet.differencecC||dSr)__isub__r?r r r rBzWeakSet.difference_updatecCs>|jr|||ur|j|S|jdd|D|S)Ncs|]}t|VqdSrr.0rr r r z#WeakSet.__isub__..)rrrr6rBr?r r r rHs zWeakSet.__isub__csfdd|DS)Nc3s|] }|vr|VqdSrr rKr*r r rMz'WeakSet.intersection..r7r?r r*r intersectionzWeakSet.intersectioncCrGr)__iand__r?r r r intersection_updaterIzWeakSet.intersection_updatecCs(|jr||jdd|D|S)NcsrJrrrKr r r rMrNz#WeakSet.__iand__..)rrrrSr?r r r rRszWeakSet.__iand__cC|jdd|DS)NcsrJrrrKr r r rMrNz#WeakSet.issubset..)rissubsetr?r r r rUzWeakSet.issubsetcCs|jttt|kSrrr"maprr?r r r __lt__r,zWeakSet.__lt__cCrT)NcsrJrrrKr r r rMrNz%WeakSet.issuperset..)r issupersetr?r r r rZrVzWeakSet.issupersetcCs|jttt|kSrrWr?r r r __gt__r,zWeakSet.__gt__cCs$t||jstS|jttt|kSr) isinstancer1NotImplementedrr"rXrr?r r r __eq__s zWeakSet.__eq__cCrAr)r8symmetric_difference_updaterCr r r symmetric_differencerFzWeakSet.symmetric_differencecCrGr)__ixor__r?r r r r_rIz#WeakSet.symmetric_difference_updatecsBjr|urjSjfdd|DS)Nc3s|] }t|jVqdSr)rr!rKr*r r rMrOz#WeakSet.__ixor__..)rrrr6r_r?r r*r ras zWeakSet.__ixor__cCs|dd||fDS)Ncss|] }|D]}|VqqdSrr )rLrrr r r rMsz WeakSet.union..r7r?r r r unionrQz WeakSet.unioncCst||dkS)Nr)r)rPr?r r r isdisjointszWeakSet.isdisjointcCs t|jSr)reprrr*r r r __repr__r9zWeakSet.__repr__r)+rrrr rr(r+r/r4rr6r8r$rrr#r@rE__sub__rBrHrP__and__rSrRrU__le__rYrZ__ge__r[r^r`__xor__r_rarb__or__rcre classmethodr__class_getitem__r r r r r$sN       N)_weakrefrtypesr__all__rrr r r r s