diff options
author | Sebastien Martini <seb@dbzteam.org> | 2011-03-22 10:36:12 -0700 |
---|---|---|
committer | Sebastien Martini <seb@dbzteam.org> | 2011-03-22 10:36:12 -0700 |
commit | fc47e5b47355e2dd1859d05c1f4a6b67976682b8 (patch) | |
tree | eb1d23b4abfa4930cbf405e65ba6f1712abecb6e | |
parent | 09d7d1614bb019d78ce64a697f9604b3e3d86c91 (diff) | |
download | pyinotify-fc47e5b47355e2dd1859d05c1f4a6b67976682b8.tar.gz |
Use __slots__ in Watch class to reduce memory footprint (contributed
by Olivier Cortès).
-rwxr-xr-x | python2/pyinotify.py | 5 | ||||
-rwxr-xr-x | python3/pyinotify.py | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/python2/pyinotify.py b/python2/pyinotify.py index 2e562f5..1372951 100755 --- a/python2/pyinotify.py +++ b/python2/pyinotify.py @@ -1575,6 +1575,9 @@ class Watch: Represent a watch, i.e. a file or directory being watched. """ + __slots__ = ('wd', 'path', 'mask', 'proc_fun', 'auto_add', + 'exclude_filter', 'dir') + def __init__(self, wd, path, mask, proc_fun, auto_add, exclude_filter): """ Initializations. @@ -1611,7 +1614,7 @@ class Watch: output_format.punctuation('='), output_format.field_value(getattr(self, attr))) \ - for attr in self.__dict__ if not attr.startswith('_')]) + for attr in self.__slots__ if not attr.startswith('_')]) s = '%s%s %s %s' % (output_format.punctuation('<'), output_format.class_name(self.__class__.__name__), diff --git a/python3/pyinotify.py b/python3/pyinotify.py index 858ab42..fcc1e79 100755 --- a/python3/pyinotify.py +++ b/python3/pyinotify.py @@ -1519,6 +1519,9 @@ class Watch: Represent a watch, i.e. a file or directory being watched. """ + __slots__ = ('wd', 'path', 'mask', 'proc_fun', 'auto_add', + 'exclude_filter', 'dir') + def __init__(self, wd, path, mask, proc_fun, auto_add, exclude_filter): """ Initializations. @@ -1555,7 +1558,7 @@ class Watch: output_format.punctuation('='), output_format.field_value(getattr(self, attr))) \ - for attr in self.__dict__ if not attr.startswith('_')]) + for attr in self.__slots__ if not attr.startswith('_')]) s = '%s%s %s %s' % (output_format.punctuation('<'), output_format.class_name(self.__class__.__name__), |