On Sat., 28 Mar. 2020, 8:39 am Guido van Rossum, <[email protected]> wrote:
> On Fri, Mar 27, 2020 at 3:29 PM Dennis Sweeney < > [email protected]> wrote: > >> > If I saw that in a code review I'd flag it for non-obviousness. One >> should >> > use 'string != new_string' unless there is severe pressure to squeeze >> > every nanosecond out of this particular code (and it better be inside an >> > inner loop). >> >> I thought that someone had suggested that such things go in the PEP, > > > I'm sure someone did. > I think that may have been me in a tangent thread where folks were worried about O(N) checks on long strings. I know at least I temporarily forgot to account for string equality checks starting with a few O(1) checks to speed up common cases (IIRC: identity, length, first code point, last code point), which means explicitly calling len() is just as likely to slow things down as it is to speed them up. Cheers, Nick. >
_______________________________________________ Python-Dev mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/UYA5ICAM6TWREXS7SSA4WKWRA2DAQOMF/ Code of Conduct: http://python.org/psf/codeofconduct/
