Message3907
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. |
|
Date |
User |
Action |
Args |
2008-12-10 17:24:43 | doublep | set | recipients:
+ doublep |
2008-12-10 17:24:42 | doublep | set | messageid: <1228929882.95.0.124854869088.issue1200@psf.upfronthosting.co.za> |
2008-12-10 17:24:42 | doublep | link | issue1200 messages |
2008-12-10 17:24:42 | doublep | create | |
|