From b52dd5b40188a47ec6869e63bae21623db7cce11 Mon Sep 17 00:00:00 2001 From: Drew Hintz Date: Thu, 7 Apr 2022 11:32:39 -0500 Subject: [PATCH] remove redundant list comprehension any() accepts a generator. This will cause it to run faster because the any() returns as soon as it finds a True value. --- html5lib/html5parser.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/html5lib/html5parser.py b/html5lib/html5parser.py index 74d829d9..9fb038b7 100644 --- a/html5lib/html5parser.py +++ b/html5lib/html5parser.py @@ -1002,8 +1002,8 @@ def processCharacters(self, token): self.tree.insertText(token["data"]) # This must be bad for performance if (self.parser.framesetOK and - any([char not in spaceCharacters - for char in token["data"]])): + any(char not in spaceCharacters + for char in token["data"])): self.parser.framesetOK = False def processSpaceCharactersNonPre(self, token): @@ -1850,7 +1850,7 @@ def __init__(self, *args, **kwargs): def flushCharacters(self): data = "".join([item["data"] for item in self.characterTokens]) - if any([item not in spaceCharacters for item in data]): + if any(item not in spaceCharacters for item in data): token = {"type": tokenTypes["Characters"], "data": data} self.parser.phases["inTable"].insertText(token) elif data: pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy