[Pyrex] status of weakref support?
Martijn Faassen
faassen at infrae.com
Sat Dec 11 20:36:48 CET 2004
Hi there,
I read the previous thread about weakref support in Pyrex, and I'm using
the following hack now in lxml:
cdef class ElementBase:
...
class Element(ElementBase):
__slots__ = ['__weakref__']
Unfortunately this is rather cumbersome, as I have many Pyrex objects
which needs to be weakreferencable, and I need to subclass them all and
worry about constructing the right now. In addition, certain operations
in Pyrex seem to be capable of 'stripping off' the weakreferenceability
in a way I do not yet understand; I noticed that if I return an object
that was originally an Element and I declare its type to be ElementBase
there's a good chance that this object will not be weakreferenceable...
This complexity could all go away if Pyrex-defined extension objects
could be weakreferenceable from the start. It would simplify lxml a lot.
I'm fine with having to declare this somewhere, as long as it's possible.
What's the thinking on what this mechanism should look like in Pyrex?
If nobody else more capable steps up, I might even try writing a patch.
Any hints on where to start?
Thank you,
Martijn
More information about the Pyrex
mailing list