Then you would have to drop the same style of optional arguments from all string methods.
There is a method to this madness: the slice arguments let you search through the string without actually making the slice copy. This matters rarely, but when it does, it can matter a lot -- imagine s being 100 MB long, and the specified slice being a large portion of that. (Yes, the string "views" that some folks would like to add could solve this in a different way. But IMO the views make everybody pay because basic usage of the string data type will be slower, and there are horrible worst-case scenarios (such as keeping one word from many 10-MB strings). We've gone over this many times without anybody ever showing a realistic bullet-proof imlpementation or performance figures other than micro-benchmarks. Perhaps someone should write a PEP so I can reject it. :-) --Guido On 8/25/06, Jim Jewett <[EMAIL PROTECTED]> wrote: > On 8/24/06, Greg Ewing <[EMAIL PROTECTED]> wrote: > > Until a few moments ago, I didn't know that str.startswith() > > had any optional arguments > > I just looked them up, and they turn out to just be syntactic sugar > for a slice. (Even to the extent of handling omitted arguments as > None.) The stop argument in particular is (almost) silly. > > s.startswith(prefix, start, stop) === s[start:stop].startswith(prefix) > > Ignoring efficiency concerns, would dropping the optional arguments > and requiring an explicit slice be a valid Py3K simplification? > > -jJ > _______________________________________________ > Python-3000 mailing list > [email protected] > http://mail.python.org/mailman/listinfo/python-3000 > Unsubscribe: > http://mail.python.org/mailman/options/python-3000/guido%40python.org > -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
