[Python-Dev] Let's stop eating exceptions in dict lookup
Armin Rigo
arigo at tunes.org
Tue May 30 00:35:57 CEST 2006
Hi Fredrik,
On Tue, May 30, 2006 at 12:23:04AM +0200, Fredrik Lundh wrote:
> well, the empty string is a valid substring of all possible strings
> (there are no "null" strings in Python). you get the same behaviour
> from slicing, the "in" operator, "replace" (this was discussed on the
> list last week), "count", etc.
>
> if you're actually searching for a *non-empty* string, find() will
> always return -1 sooner or later.
I know this. These corner cases are debatable and different answers
could be seen as correct, as I think is the case for find(). My point
was different: I was worrying that the recent change in str.find() would
needlessly send existing and working programs into infinite loops, which
can be a particularly bad kind of failure for some applications.
At least, it gave a 100% performance loss on the benchmark I was trying
to run :-)
A bientot,
Armin.
More information about the Python-Dev
mailing list