From b90f34569f39106c3a62a6b6087e9f0d70508190 Mon Sep 17 00:00:00 2001
From: Ran Benita <ran@unusedvar.com>
Date: Thu, 30 Apr 2020 16:08:24 +0300
Subject: [PATCH] nodes: micro-optimize Node attribute access

---
 src/_pytest/nodes.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py
index 0a1f89c74..56c1d4404 100644
--- a/src/_pytest/nodes.py
+++ b/src/_pytest/nodes.py
@@ -91,6 +91,19 @@ class Node(metaclass=NodeMeta):
     """ base class for Collector and Item the test collection tree.
     Collector subclasses have children, Items are terminal nodes."""
 
+    # Use __slots__ to make attribute access faster.
+    # Note that __dict__ is still available.
+    __slots__ = (
+        "name",
+        "parent",
+        "config",
+        "session",
+        "fspath",
+        "_nodeid",
+        "_store",
+        "__dict__",
+    )
+
     def __init__(
         self,
         name: str,