Use __slots__ for dependencies.Node

The number of nodes in the dependency graph is not huge (one per resource),
but we tend to make a lot of copies - the whole graph must be copied every
time we iterate through it. Since the Node class has only two attributes
and is basically never modified, we can easily save a little memory by
defining __slots__ for it.

Change-Id: Ibe36016a5889c9f1bd89672b1b03b2bc69b7925b
This commit is contained in:
Zane Bitter 2016-12-01 15:35:15 -05:00
parent da5ba93048
commit c93e44dc1e
1 changed files with 2 additions and 0 deletions

View File

@ -30,6 +30,8 @@ class CircularDependencyException(exception.HeatException):
class Node(object):
"""A node in a dependency graph."""
__slots__ = ('require', 'satisfy')
def __init__(self, requires=None, required_by=None):
"""Initialisation of the node.