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