Case-insensitive string compare?
Maric Michaud
maric at aristote.info
Fri Sep 5 07:31:40 EDT 2008
Le Friday 05 September 2008 08:24:29 Fredrik Lundh, vous avez écrit :
> Maric Michaud wrote:
> > "premature optimization is the root of all evil"
>
> So is use by that statement by people who don't have the slightest idea
> about what it actually means.
>
> The full version is
>
> "We should forget about small efficiencies, say about 97% of the time:
> premature optimization is the root of all evil."
>
> Note the use of "small efficiencies". That is, in Python, things like
> local binding, inlining, slots, lazy generation of short sequences, etc.
> That is, things that takes time to write and reduces maintainability.
>
> It's not about having an excuse for writing crappy code with large
> inefficienies.
>
> And it's definitely not about programmers intentionally picking a dumb
> solution so they can optimize it later.
>
Yes, I'm aware of that, thanks, but Chris Rebert was proposing to alter the
data structure in order to achieve this simple comparison, I don't think it
fails into your concern.
> > If the OP's proposal seems already messy, how about ths one :
> > if lib.lower() not in ( e[0] for e in stage_map.items() ) :
> > ...
>
Sorry, should be read :
if lib.lower() not in ( e[0] for e in stage_map.values() ) :
and it was the expression for comparison Chris's solution lead to, not a
proposal.
> Given that your solution is just a remarkably inefficient way to write
> "lib.lower() not in stage_map", and thus doesn't solve the OP:s problem,
> I suspect you're taking the "evil" part of Hoare's dictum a few bits too
> literally.
>
I suspect you are coming to conclusions a bit quickly, without taking the pain
of understanding the whole discussion.
> </F>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
--
_____________
Maric Michaud
More information about the Python-list
mailing list