Lisandro Dalcin wrote: > On Tue, Feb 24, 2009 at 4:26 PM, Stefan Behnel <[email protected]> wrote: >> Dag Sverre Seljebotn wrote: >>> 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. > > Where would you hold a reference to such closure?
The type itself would hold it. During module creation, all types that require GC will be copied to the heap, and their closure will be initialised. That way, the module would hold a reference to a complete set of all globals, types and functions, and the types would hold a reference only to their own closure. No reference cycles so far. Module-level functions would not need a closure as they get their module reference passed as self argument and can use it to reference the right globals. Cdef module functions are a problem, though, as they don't have a self argument. Not sure how to deal with that. >> I so like the idea of implementing these things under the hood, instead of >> requiring users to rewrite their code. > > Unless these things are related to bytes/unicode management, right? > Just joking ;-) ... I hope so. Unicode handling isn't about additional functionality, it's about correctness and safety. Stefan _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
