perf(parser): A lot of optimizations to speed things up

This commit is contained in:
Karim shoair
2025-08-01 05:42:32 +03:00
parent af5f3688c1
commit df48662c00
3 changed files with 39 additions and 37 deletions
+2 -4
View File
@@ -10,9 +10,7 @@ from scrapling.core._types import Any, Dict, Iterable, List
# Using cache on top of a class is a brilliant way to achieve a Singleton design pattern without much code
from functools import lru_cache # isort:skip
html_forbidden = {
html.HtmlComment,
}
html_forbidden = (html.HtmlComment,)
__CLEANING_TABLE__ = str.maketrans({"\t": " ", "\n": None, "\r": None})
__CONSECUTIVE_SPACES_REGEX__ = re_compile(r" +")
@@ -108,7 +106,7 @@ class _StorageTools:
children = [
child.tag
for child in element.iterchildren()
if type(child) not in html_forbidden
if not isinstance(child, html_forbidden)
]
if children:
result.update({"children": tuple(children)})