[Python-3000] simplifying methods (was: Re: Droping find/rfind?)

Guido van Rossum guido at python.org
Fri Aug 25 19:37:44 CEST 2006

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

(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. :-)


On 8/25/06, Jim Jewett <jimjjewett at gmail.com> wrote:
> On 8/24/06, Greg Ewing <greg.ewing at canterbury.ac.nz> 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
> Python-3000 at python.org
> 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/)

More information about the Python-3000 mailing list