[Python-Dev] Why aren't more things weak referencable (original) (raw)
Raymond Hettinger raymond.hettinger at verizon.net
Sat May 29 13:06:31 EDT 2004
- Previous message: [Python-Dev] cPickle bug (was: Saving recursive objects to disc. cPickle wan't work)
- Next message: [Python-Dev] Why aren't more things weak referencable
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Instances of classes inheriting from str, tuple, etc cannot be weakly referenced. Does anyone know the reason for this?
from weakref import proxy class Object(object): pass
x = Object() y = proxy(x) # no problem here class Str(str): pass
x = Str() y = proxy(x) # but why won't this work?
Traceback (most recent call last): File "<pyshell#9>", line 1, in -toplevel- y = proxy(x) TypeError: cannot create weak reference to 'Str' object
Weak referencing would be much more useful to me if it included strings, tuples, and such. Right now, my awkward workaround is substituting UserString or some other wrapper class replacing inheritance with delegation.
Raymond Hettinger
-------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-dev/attachments/20040529/1ab23f85/attachment.html
- Previous message: [Python-Dev] cPickle bug (was: Saving recursive objects to disc. cPickle wan't work)
- Next message: [Python-Dev] Why aren't more things weak referencable
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]