[Python-3000] Making strings non-iterable
Ian Bicking
ianb at colorstudy.com
Tue Apr 18 02:34:53 CEST 2006
Guido van Rossum wrote:
> On 4/17/06, Ian Bicking <ianb at colorstudy.com> wrote:
>
>>The proposal wasn't to remove iterability in general, only to require
>>the use of an explicit method when iterating over strings. It's not a
>>huge change by any means; a speed bump for a small number of people,
>>perhaps, but no real functionality would be removed. Backward
>>compatibility is also certainly a concern -- and what seems to have
>>soured Guido on the idea as much as anything -- but that doesn't seem to
>>be what has you bothered.
>
>
> "A speed bump for a small number of people"? "No real functionality
> remove"? You gotta be kidding. It drops polymorphism between strings
> and other sequences. This is not just of theoretical value -- difflib
> relies on this, for example. Your (earlier) assertion that the stdlib
> is atypical is wishful thinking; the stdlib contains lots of code just
> like code written by regular people. Perhaps you've had Perl on your
> mind too much recently?
Polymorphism between things that aren't similar is bad; in another
context it is called implicit coersion, like '1'+2=='12'. That's what
string iteration looks like to me -- strings aren't sequences of
strings. It can be convenient to treat them like sequences, but lots of
things can be convenient, including '1'+2=='12'.
But I can accept and understand that the change introduces too many
backward compatibility problems, especially subtle ones like removing
type equivalencies, which can be very hard to detect or resolve.
--
Ian Bicking / ianb at colorstudy.com / http://blog.ianbicking.org
More information about the Python-3000
mailing list