>> Can you explain this a bit more? I presume you're talking about >> subclassing in C > > Yes, I mentioned Cython above.
Can you please still elaborate? I have never used Cython before, but if it cannot efficiently subclass str, isn't that a bug in Cython? >> I do note that the mechanisms that exist for supporting adding a __dict__ >> to a str (in 2.x; or bytes in 3.x) or a tuple could be extended for other >> purposes. > > I never looked into these, but this does not sound like it would impact > subclassing. To me, the relationship is fairly straight: if you want to subclass a type, *all* you need is a way to place an __dict__ in the object, if it doesn't already have one. If the base object already has an __dict__, the layout of the subtype can be the same as the layout of the base type. Now, what Guido (probably) refers to is the implementation strategy used for adding __dict__ could be generalized for adding additional slots as well: for a variable-sized object (str or tuple), the dictoffset is negative, indicating that you have to count from the end of the object, not from the start, to find the slot. So if you are worried about __dict__-stored attributes being too slow (*), this approach could be a solution. (*) This assumes that the lack of additional slots actually *is* your concern. Regards, Martin _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com