Issue1200
Created on 2008-12-10.17:24:42 by doublep, last changed 2009-04-10.03:32:53 by pjenvey.
msg3907 (view) |
Author: (doublep) |
Date: 2008-12-10.17:24:42 |
|
I know that Java weak reference are implemented differently, e.g. all
objects are inherently weak-referencable and __weakref__ slot is
meaningless. Still, Jython could add special handling for the slot to
simplify things for code that blindly (not checking exact
implementation) uses it.
E.g.:
class X (object):
__slots__ = ('__weakref__')
x = X ()
x.__weakref__ = 1
This code fails in CPython but works fine in Jython. However, it wastes
one slot, making each object unnecessarily larger (I admit I don't
really know how Jython works, but that's what I guess it results in).
Also, it seems Jython is capable of not creating duplicate weakref object:
>>> a = object ()
>>> b = weakref.ref (a)
>>> c = weakref.ref (a)
>>> b, c, b is c
(<weakref at 1; to 'object' at 2>, <weakref at 1; to 'object' at 2>, True)
so x.__weakref__ (descriptor getter) could be implemented as in CPython.
I'm not proposing to artificially limit set of weak-referencable types
--- I'm just asking to make __weakref__ slot "just work as intended"
without caring whether it is CPython or Jython.
|
msg3910 (view) |
Author: Philip Jenvey (pjenvey) |
Date: 2008-12-10.23:03:56 |
|
I've been intending to do this for 2.5, thanks for the reminder
|
msg4499 (view) |
Author: Philip Jenvey (pjenvey) |
Date: 2009-04-10.03:32:52 |
|
fixed in r6198, thanks
|
|
Date |
User |
Action |
Args |
2009-04-10 03:32:53 | pjenvey | set | status: open -> closed resolution: accepted -> fixed messages:
+ msg4499 |
2009-03-14 02:43:08 | fwierzbicki | set | priority: high |
2008-12-10 23:03:56 | pjenvey | set | assignee: pjenvey resolution: accepted messages:
+ msg3910 nosy:
+ pjenvey |
2008-12-10 17:24:42 | doublep | create | |
|