PEP 358 and operations on bytes
Steve Holden
steve at holdenweb.com
Tue Oct 3 23:50:55 EDT 2006
Ben Finney wrote:
> Steve Holden <steve at holdenweb.com> writes:
>
>
>>This would just be bloat
>
>
> How would it be bloat? I'm describing a situation where the existing
> methods merely move, being implemented in a common ancestor rather
> than directly in the concrete sequence classes.
>
>
>>without any use cases being demonstrated. What is your crying need
>>for these methods?
>
>
> I don't think I claimed a crying need for one. Consistency, where not
> foolish, is desirable.
>
> I don't deny that there is work involved; my suggestion was in the
> context of talking about a common ancestor to 'bytes' and 'str', in
> order to refactor some of the common methods.
>
>
>>Your *real* generalisation of the string method would actually
>>require you to write
>>
>> ["foo", "bar", "spam", "baz", "quux", "wibble"].startswith(["foo"])
>
>
> Yes, you're right. I realised that after sending, but didn't correct
> it.
>
>
>>Python didn't get to be the language it is today by adding
>>unnecessary hypergeneralisations on a whim. Show me how these
>>methods will improve the daily lives of programmers and I'll
>>champion them to the developers, but I don't think the world will be
>>beating a path to your door.
>
>
> Again, I'm discussing a still-nascent suggestion for a common sequence
> ancestor; there are no demands here. If there is to be generalisation,
> I'm merely pointing out that it could be at a higher level and be more
> useful.
>
> If nothing else, it would lend more coherence to the "str is a
> sequence" confusion if *all* sequences shared some str-derived
> methods.
>
Unfortunately this is where your argument falls to the ground. Strings
really are special, since each element of a string is another string.
What confusion?
Any proposal that tries to make strings and lists subclasses of a common
ancestor is doomed to failure: strings are highly optimised for
performance (in Python and in other languages), and the optimisations
just wouldn't translate to a "generic sequence". That's just life in the
real world.
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
More information about the Python-list
mailing list