Patches item #1229239, was opened at 2005-06-28 11:57 Message generated for change (Comment added) made by gregcouch You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1229239&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Core (C code) Group: Python 2.4 Status: Open Resolution: None Priority: 5 Submitted By: Greg Couch (gregcouch) Assigned to: Nobody/Anonymous (nobody) Summary: optionally allow mutable builtin types Initial Comment: Non-heap types, aka builtin types, cannot have their attributes changed by Python code -- see Objects/typeobject.c: type_setattro(). This limitation is good for Python's core builtin types (int, float, list, dict, ...), but not necessarily for non-heap types in extension modules. The attached patch allows for non-heap types to mutate iff the Py_TPFLAGS_MUTABLE_BUILTIN flag is set. ---------------------------------------------------------------------- >Comment By: Greg Couch (gregcouch) Date: 2005-07-15 00:26 Message: Logged In: YES user_id=131838 One reason that the type wasn't a heap type was because I didn't find an example in the Python documentation. And because when I was looking through typeobject.c, I saw code, like type_get_doc(), that ignores the (tp_doc) slot when it is a heap type -- exactly what I don't want (looking closer, it may be the only one). I also like most of the restrictions a non-heap type has, like being unable to change its name. So if heap types are as fast as non-heap types, then I have no objection to switching. I'm also concerned about the additional startup time switching to heap types would cost since I currently have 75 types in my module. The python code that prompted this patch was code that reached in and added extra keyword arguments to a method, sort of like a decorator, for additional bookkeeping. Subclassing is out because the C (C++) object factory function only returns the instances of the original type. ---------------------------------------------------------------------- Comment By: Martin v. Löwis (loewis) Date: 2005-07-11 09:44 Message: Logged In: YES user_id=21627 Why can't you create such a type as a heap type? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1229239&group_id=5470 _______________________________________________ Patches mailing list [email protected] http://mail.python.org/mailman/listinfo/patches
