On Fri, 11 Nov 2016 08:12:57 -0800 (PST) "Edward K. Ream" <[email protected]> wrote:
> On Thursday, November 10, 2016 at 12:48:28 PM UTC-6, Edward K. Ream > wrote: > > > > Up until today, I have always tested for an empty string using not > > s.strip(). But Doh, this is an unnecessary stress on the GC. > > `s.isspace()` much faster and more pythonic. > > > > As another aspect of this pattern, instead of testing, > > if ''.join(lines): > > the new code now tests: > > if all([z.isspace() for z in lines]): Those don't seem equivalent - the first is true if any of lines is anything other than "", the second only if all lines are whitespace, and none are "". But I suspect these were typed into email, rather than copy pasted from code? Cheers -Terry > This is much faster (it should run close to C speed) and generates > *no* additional strings for the GC to recycle. > > EKR > > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.
