[MERGE] BTreeIndex intern()

John Arbash Meinel john at arbash-meinel.com
Wed Apr 8 22:40:26 BST 2009


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

Robert Collins wrote:
> On Wed, 2009-04-08 at 15:38 -0500, John Arbash Meinel wrote:
>> +    __slots__ = ('keys')
> 
> Shouldn't this be ('keys',) ?
> 
> Anyhow,
> bb:approve
> 
> I do worry that 'intern' is simply the wrong hammer to be using here :(.
> 
> -Rob

Oddly enough, it works fine, otherwise I would agree with you. I'll
certainly change it, but perhaps python allows single strings to
indicate a single attribute.

I generally would agree that intern() isn't the best solution, however
it has the really *good* property that it doesn't make the string
immortal. So if you intern() and the last general reference goes away,
it gets removed from the intern dict as part of the deallocation process
for strings.

If there was any way to hook the string deallocation mechanism so that
you could do something similar with your own object, I would be very
happy to do so. Probably with some C hackery you could override the
PyStringType.tp_dealloc pointer, but I'd leave that as an exercise to
the user for now.

Not to mention you can't intern() tuples, which would also be useful for
*us*.

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

iEYEARECAAYFAkndGcoACgkQJdeBCYSNAAOK/ACgkleMcc4puTMrNEKErdymY/35
PegAniBeTlUGAs//g6d2zxcAFeECI//b
=yGFb
-----END PGP SIGNATURE-----



More information about the bazaar mailing list