Using __slots__ in more places, in particular, hosts and groups, where we are apt to create a fair amount of objects.

This commit is contained in:
Michael DeHaan 2012-07-22 11:40:02 -04:00
parent 84e1d21b9c
commit 57f12ac9e3
4 changed files with 9 additions and 0 deletions

View file

@ -35,6 +35,9 @@ class Inventory(object):
Host inventory for ansible.
"""
__slots__ = [ 'host_list', 'groups', '_restriction', '_is_script',
'parser' ]
def __init__(self, host_list=C.DEFAULT_HOST_LIST):
# the host file file, or script path, or list of hosts

View file

@ -18,6 +18,8 @@
class Group(object):
''' a group of ansible hosts '''
__slots__ = [ 'name', 'hosts', 'vars', 'child_groups', 'parent_groups' ]
def __init__(self, name=None):
self.name = name

View file

@ -21,6 +21,8 @@ import ansible.constants as C
class Host(object):
''' a single ansible host '''
__slots__ = [ 'name', 'vars', 'groups' ]
def __init__(self, name=None, port=None):
self.name = name

View file

@ -25,6 +25,8 @@ import sys
class InventoryParserYaml(object):
''' Host inventory parser for ansible '''
__slots__ = [ '_hosts', 'groups' ]
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" +