Skip to content

Commit 5decf47

Browse files
authored
remove redundant list comprehension (html5lib#547)
any() accepts a generator. This will cause it to run faster because the any() returns as soon as it finds a True value.
1 parent 6815a54 commit 5decf47

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

html5lib/html5parser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,8 +1002,8 @@ def processCharacters(self, token):
10021002
self.tree.insertText(token["data"])
10031003
# This must be bad for performance
10041004
if (self.parser.framesetOK and
1005-
any([char not in spaceCharacters
1006-
for char in token["data"]])):
1005+
any(char not in spaceCharacters
1006+
for char in token["data"])):
10071007
self.parser.framesetOK = False
10081008

10091009
def processSpaceCharactersNonPre(self, token):
@@ -1850,7 +1850,7 @@ def __init__(self, *args, **kwargs):
18501850

18511851
def flushCharacters(self):
18521852
data = "".join([item["data"] for item in self.characterTokens])
1853-
if any([item not in spaceCharacters for item in data]):
1853+
if any(item not in spaceCharacters for item in data):
18541854
token = {"type": tokenTypes["Characters"], "data": data}
18551855
self.parser.phases["inTable"].insertText(token)
18561856
elif data:

0 commit comments

Comments
 (0)
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