summaryrefslogtreecommitdiff
path: root/systrace/catapult/common/py_utils/py_utils/slots_metaclass.py
diff options
context:
space:
mode:
Diffstat (limited to 'systrace/catapult/common/py_utils/py_utils/slots_metaclass.py')
-rw-r--r--systrace/catapult/common/py_utils/py_utils/slots_metaclass.py27
1 files changed, 0 insertions, 27 deletions
diff --git a/systrace/catapult/common/py_utils/py_utils/slots_metaclass.py b/systrace/catapult/common/py_utils/py_utils/slots_metaclass.py
deleted file mode 100644
index ae36c67..0000000
--- a/systrace/catapult/common/py_utils/py_utils/slots_metaclass.py
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright 2017 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-class SlotsMetaclass(type):
- """This metaclass requires all subclasses to define __slots__.
-
- Usage:
- class Foo(object):
- __metaclass__ = slots_metaclass.SlotsMetaclass
- __slots__ = '_property0', '_property1',
-
- __slots__ must be a tuple containing string names of all properties that the
- class contains.
- Defining __slots__ reduces memory usage, accelerates property access, and
- prevents dynamically adding unlisted properties.
- If you need to dynamically add unlisted properties to a class with this
- metaclass, then take a step back and rethink your goals. If you really really
- need to dynamically add unlisted properties to a class with this metaclass,
- add '__dict__' to its __slots__.
- """
-
- def __new__(mcs, name, bases, attrs):
- assert '__slots__' in attrs, 'Class "%s" must define __slots__' % name
- assert isinstance(attrs['__slots__'], tuple), '__slots__ must be a tuple'
-
- return super(SlotsMetaclass, mcs).__new__(mcs, name, bases, attrs)