Commit 57f12ac9 by Michael DeHaan

Using __slots__ in more places, in particular, hosts and groups, where we are…

Using __slots__ in more places, in particular, hosts and groups, where we are apt to create a fair amount of objects.
parent 84e1d21b
...@@ -35,6 +35,9 @@ class Inventory(object): ...@@ -35,6 +35,9 @@ class Inventory(object):
Host inventory for ansible. Host inventory for ansible.
""" """
__slots__ = [ 'host_list', 'groups', '_restriction', '_is_script',
'parser' ]
def __init__(self, host_list=C.DEFAULT_HOST_LIST): def __init__(self, host_list=C.DEFAULT_HOST_LIST):
# the host file file, or script path, or list of hosts # the host file file, or script path, or list of hosts
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
class Group(object): class Group(object):
''' a group of ansible hosts ''' ''' a group of ansible hosts '''
__slots__ = [ 'name', 'hosts', 'vars', 'child_groups', 'parent_groups' ]
def __init__(self, name=None): def __init__(self, name=None):
self.name = name self.name = name
......
...@@ -21,6 +21,8 @@ import ansible.constants as C ...@@ -21,6 +21,8 @@ import ansible.constants as C
class Host(object): class Host(object):
''' a single ansible host ''' ''' a single ansible host '''
__slots__ = [ 'name', 'vars', 'groups' ]
def __init__(self, name=None, port=None): def __init__(self, name=None, port=None):
self.name = name self.name = name
......
...@@ -25,6 +25,8 @@ import sys ...@@ -25,6 +25,8 @@ import sys
class InventoryParserYaml(object): class InventoryParserYaml(object):
''' Host inventory parser for ansible ''' ''' Host inventory parser for ansible '''
__slots__ = [ '_hosts', 'groups' ]
def __init__(self, filename=C.DEFAULT_HOST_LIST): def __init__(self, filename=C.DEFAULT_HOST_LIST):
sys.stderr.write("WARNING: YAML inventory files are deprecated in 0.6 and will be removed in 0.7, to migrate" + sys.stderr.write("WARNING: YAML inventory files are deprecated in 0.6 and will be removed in 0.7, to migrate" +
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment