[Python-bugs-list] [ python-Bugs-451773 ] new-style objects not weak-referencable
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 17 Aug 2001 11:57:36 -0700
Bugs item #451773, was opened at 2001-08-16 15:19
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=451773&group_id=5470
Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Fred L. Drake, Jr. (fdrake)
Assigned to: Guido van Rossum (gvanrossum)
Summary: new-style objects not weak-referencable
Initial Comment:
Objects using the new-style class types are not weakly referencable:
>>> import weakref
>>> class MyClass(object):
... pass
...
>>> o = MyClass()
>>> weakref.ref(o)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: 'MyClass' objects are not weakly referencable
----------------------------------------------------------------------
>Comment By: Guido van Rossum (gvanrossum)
Date: 2001-08-17 11:57
Message:
Logged In: YES
user_id=6380
This is a little tricker than I thought.
I don't want to enable weak-referencing for the 'object'
type, because that would add a weak reference slot to every
type (even list, dictionary etc.).
So I have to add a weakref slot at the same time that I add
the __dict__. But then types using __slots__ are not
weak-referenceable.
Ideally, weak-referenceability might be a user option,
default on for types with a __dict__ but default of for
types that use __slots__ only.
Fred, would it be a safety issue if the list of weak
references were made available as a __weakrefs__ special
slot (if present)?
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=451773&group_id=5470