Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

save huge models to slots -> HUGE speedup

Gregor Žunič73413ee15ced
diff --git a/browser_use/dom/playground/tree.py b/browser_use/dom/playground/tree.py
index 8f633e716..cad974930 100644
--- a/browser_use/dom/playground/tree.py
+++ b/browser_use/dom/playground/tree.py
@@ -41,7 +41,7 @@ async def main():
# print('saved ax tree to tmp/ax_tree.json')
print('Done')
-
+
if __name__ == '__main__':
asyncio.run(main())
diff --git a/browser_use/dom/views.py b/browser_use/dom/views.py
index b072182ea..3a6c942f3 100644
--- a/browser_use/dom/views.py
+++ b/browser_use/dom/views.py
@@ -54,7 +54,7 @@ class NodeType(int, Enum):
# text: str | None
-@dataclass
+@dataclass(slots=True)
class EnhancedAXProperty:
"""we don't need `sources` and `related_nodes` for now (not sure how to use them)
@@ -66,7 +66,7 @@ class EnhancedAXProperty:
# related_nodes: list[EnchancedAXRelatedNode] | None
-@dataclass
+@dataclass(slots=True)
class EnhancedAXNode:
ax_node_id: str
"""Not to be confused the DOM node_id. Only useful for AX node tree"""
@@ -79,7 +79,7 @@ class EnhancedAXNode:
properties: list[EnhancedAXProperty] | None
-@dataclass
+@dataclass(slots=True)
class EnhancedDOMTreeNode:
"""
Enchanced DOM tree node that contains information from AX, DOM, and Snapshot trees. It's mostly based on the types on DOM node type with enchanced data from AX and Snapshot trees.