Stefan Behnel wrote:
> Hi,
> 
> Dag Sverre Seljebotn wrote:
>> Stefan Behnel wrote:
>>> Hmm, true. When each object references its type, which in turn references
>>> the module instance, which in turn references the type, that means that
>>> *all* objects created in a module will end up requiring the GC due to
>>> reference cycles.
>>>
>>> I guess we need to raise these issues on python-dev. They'll be happy to
>>> dig into the real-life issues anyway. I'm pretty sure we'd be the first to
>>> actually use the new module features.
>>>
>>>> In any case, the only way to write safe code is to avoid the usage of
>>>> module-level globals in __del__() and __dealloc__() methods...
>>> Which is a rare thing anyway. Most of the time, you'd just call some kind
>>> of free() function and be done.
>> If it turns out these reference cycles will be a problem, I think we 
>> could always change Cython to *not* use initialized constants in __del__ 
>> and __dealloc__? (i.e. construct them on need; meaning a small 
>> performance penalty).
> 
> Plus, we could generate an external closure for a type (not for the
> instance, just the type object) that keeps all referenced global values.
> The type would then reference that instead of the module.

Ah, nice idea; that can be done right away (= right after 0.11) without 
#144, can it not?

I.e. let all global values be referenced by a big tuple; then have each 
type and the module reference the tuple, but the tuple itself doesn't 
reference anything but the values themselves => no cycles.

-- 
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to