Hi, What is the recommended way to implement a parent that needs a fast element constructor but otherwise can be expected not to be queried too often once the coercion maps involving it are set up ? (I would like MyParent(obj) to have as little overhead as possible, not just coercions.)
I can think of two main options: (1) Implement the parent as a Cython extension class. Tell users not to construct instances directly, and provide a (weakly) cached factory function or a UniqueFactory to be used instead. This appears to be the most common approach in Sage. (2) Implement the parent as a Python class. A benefit is that we can inherit from Singleton or UniqueRepresentation (and perhaps other similar utility classes?) as appropriate. I also seem to remember that having a true Python class avoids at least some getattr hackery related to categories, but I don't remember to what extent. Provide the element constructor as a cpdef function outside, as a direct call to the (Cython) element class, or perhaps even as a method of a Cython "shadow class" storing any necessary parameters. This does not seem to be widely used, a notable exception being QQ. The version with parameters is not used at all as far as I can tell. Any advice? Thanks, -- Marc -- You received this message because you are subscribed to the Google Groups "sage-combinat-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-combinat-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-combinat-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-combinat-devel. For more options, visit https://groups.google.com/d/optout.