nodes: micro-optimize Node attribute access

This commit is contained in:
Ran Benita 2020-04-30 16:08:24 +03:00
parent 5702c86f4c
commit b90f34569f
1 changed files with 13 additions and 0 deletions

View File

@ -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,