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. I so like the idea of implementing these things under the hood, instead of requiring users to rewrite their code. > The global constants system could need a cleanup anyway/move to code > generation time (low priority in itself though). If that was done, > change the behaviour of constants in __del__ etc. would be rather easy. > > http://trac.cython.org/cython_trac/ticket/144 Yep, I guess it makes sense to let 218 depend on this. Stefan _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
