Message175378
| Author |
pitrou |
| Recipients |
fdrake, pitrou, tim.peters |
| Date |
2012年11月11日.18:07:35 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1352657255.44.0.0509101223416.issue16453@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Dead weakrefs to a given object happen to be equal if they don't have a callback, but unequal if they do. However, they are always equal when alive:
>>> class O: pass
...
>>> o = O()
>>> def cb(_): pass
...
>>> q = weakref.ref(o)
>>> r = weakref.ref(o)
>>> s = weakref.ref(o, cb)
>>> t = weakref.ref(o, cb)
>>> q == r
True
>>> s == t
True
>>> del o
>>> q() is None
True
>>> q == r
True
>>> s == t
False
This may be related to the following optimization (?):
>>> q is r
True
>>> s is t
False |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2012年11月11日 18:07:35 | pitrou | set | recipients:
+ pitrou, tim.peters, fdrake |
| 2012年11月11日 18:07:35 | pitrou | set | messageid: <1352657255.44.0.0509101223416.issue16453@psf.upfronthosting.co.za> |
| 2012年11月11日 18:07:35 | pitrou | link | issue16453 messages |
| 2012年11月11日 18:07:35 | pitrou | create |
|