Hi Erik On 2018-05-28, Erik Bray <erik.m.b...@gmail.com> wrote: > I think Sage could use a better way to keep > track of and/or enforce immutability of classes (that is, instances of > classes). For example, have some base class which can be used as a > mix-in (or an ABC) that designates something as immutable, and > disallow assigning any attributes to its dict that aren't also > immutable (including of course support for all the common built-in > types).
I don't think this could possibly work. But actually that's not a Sage problem but a Python problem: Perhaps somewhere in the Python ecosystem such a mix-in class exists? However, I find your notion of immutability ("do not allow assigning attributes and make all existing attributes immutable") far too narrow. IIRC, immutable means that once the object is created, its equivalence class with respect to the "==" operator will be preserved no matter what of its (no-underscore?) methods are called. Thus, I believe it must be allowed to assign to an attribute of object X, as long as the behaviour of X==Y remains unchanged for all objects Y (and of course hash(X) doesn't change either). Best regards, Simon -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.