On 8/23/06, Jim Jewett <jimjjewett@gmail.com> wrote:
(1) I would personally prefer
if (step == 1) { if (start == 0 && ...) {} else {} }
I realize that the compiler can do this, but I like flagging "this is an odd special case"
Well, they are two separate special cases. I personally prefer to keep them separate this way, and it reduces indentation level. (2) Why the CheckExact? Is there a promise (even in py3K) that
constructors won't return a subclass? I had thought that the question was only when/if to *guarantee* that the subclass would be used. If the intent is to guard against subclasses with a different internal layout, then it should come before the GET_SIZE macros.
As the checkin message says, those special cases are actually taken from normal slicing. It's safe for s[:] to return s only for exact instances of string (and unicode, and tuple) since it's completely equivalent. The same is not true for subclasses -- it might be, but it doesn't have to be. The issue isn't memory layout, it's mutability and type. Memory layout should be the same, anyway -- that's how C-type-subclasses work. There are explicit checks for this behaviour, by the way. -- Thomas Wouters <thomas@python.org> Hi! I'm a .signature virus! copy me into your .signature file to help me spread!