[MERGE] Extend -Dhpss to emit a count of HPSS calls to stderr

John Arbash Meinel john at arbash-meinel.com
Fri Sep 26 02:01:37 BST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Robert Collins wrote:
> On Fri, 2008-09-26 at 09:17 +1000, Andrew Bennetts wrote:
>> I considered using repr(medium) as the dict key, but it isn't robust.
>> It's
>> possible (if unlikely) for two media to have the same repr: memory
>> addresses get
>> re-used, and also someone might one day decide to change
>> SmartClientMedium's
>> repr to omit the id.
>>
>> It is harder, but not *that* much harder, to do it robustly with
>> weakrefs, so I
>> did.
> 
> I thought there was a weakref dict supplied by python that will
> JustWork ?
> 
> -Rob

I think the problem is you need to know when the object goes away, and I
don't think a weakref dict gives you that. (I could be wrong.)

But I'm guessing if you did:

counts = WeakValueDictionary()

counts[medium] = 0

when you're done, the value has disappeared, so you can't get to
count[old_medium] == 10.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkjcNHEACgkQJdeBCYSNAAPp7ACfcV05WQVuVDRamLi5tcyTxVTM
ALgAn3Ns89Hg6vVVqC1K01wTAWLins61
=LYWZ
-----END PGP SIGNATURE-----



More information about the bazaar mailing list