Ticket #12826: introduce_slots.patch

File introduce_slots.patch, 4.4 KB (added by Sebastian Noack, 15 years ago)
  • django/django/db/models/expressions.py

    diff --git a/django/django/db/models/expressions.py b/django/django/db/models/expressions.py
    index e54aaba..d4b9c3f 100644
    a b class ExpressionNode(tree.Node):  
    77    """
    88    Base class for all query expressions.
    99    """
     10    __slots__ = ()
     11
    1012    # Arithmetic connectors
    1113    ADD = '+'
    1214    SUB = '-'
    class F(ExpressionNode):  
    9799    """
    98100    An expression representing the value of the given field.
    99101    """
     102    __slots__ = ('name',)
     103
    100104    def __init__(self, name):
    101105        super(F, self).__init__(None, None, False)
    102106        self.name = name
  • django/django/db/models/query_utils.py

    diff --git a/django/django/db/models/query_utils.py b/django/django/db/models/query_utils.py
    index 6a6b690..66ac5eb 100644
    a b class Q(tree.Node):  
    140140    Encapsulates filters as objects that can then be combined logically (using
    141141    & and |).
    142142    """
     143    __slots__ = ()
     144
    143145    # Connection types
    144146    AND = 'AND'
    145147    OR = 'OR'
  • django/django/db/models/sql/where.py

    diff --git a/django/django/db/models/sql/where.py b/django/django/db/models/sql/where.py
    index ec0545c..6f55d63 100644
    a b class WhereNode(tree.Node):  
    3232    params]. However, a child could also be any class with as_sql() and
    3333    relabel_aliases() methods.
    3434    """
     35    __slots__ = ()
     36
    3537    default = AND
    3638
    3739    def add(self, data, connector):
  • django/django/http/__init__.py

    diff --git a/django/django/http/__init__.py b/django/django/http/__init__.py
    index 683212f..e2e8b67 100644
    a b class QueryDict(MultiValueDict):  
    131131    Values retrieved from this class are converted from the given encoding
    132132    (DEFAULT_CHARSET by default) to unicode.
    133133    """
     134    __slots__ = ('_mutable', '_encoding')
     135
    134136    # These are both reset in __init__, but is specified here at the class
    135137    # level so that unpickling will have valid values
    136138    _mutable = True
  • django/django/utils/datastructures.py

    diff --git a/django/django/utils/datastructures.py b/django/django/utils/datastructures.py
    index 85cdd44..3dc73ab 100644
    a b class MergeDict(object):  
    66    If a key appears in more than one of the given dictionaries, only the
    77    first occurrence will be used.
    88    """
     9    __slots__ = ('dicts',)
     10
    911    def __init__(self, *dicts):
    1012        self.dicts = dicts
    1113
    class SortedDict(dict):  
    5456    """
    5557    A dictionary that keeps its keys in the order in which they're inserted.
    5658    """
     59    __slots__ = ('keyOrder',)
     60
    5761    def __new__(cls, *args, **kwargs):
    5862        instance = super(SortedDict, cls).__new__(cls, *args, **kwargs)
    5963        instance.keyOrder = []
    class MultiValueDict(dict):  
    185189    which returns a list for every key, even though most Web forms submit
    186190    single name-value pairs.
    187191    """
     192    __slots__ = ()
     193
    188194    def __init__(self, key_to_list_mapping=()):
    189195        super(MultiValueDict, self).__init__(key_to_list_mapping)
    190196
    class DotExpandedDict(dict):  
    353359    >>> DotExpandedDict({'c.1': 2, 'c.2': 3, 'c': 1})
    354360    {'c': 1}
    355361    """
     362    __slots__ = ()
     363
    356364    def __init__(self, key_to_list_mapping):
    357365        for k, v in key_to_list_mapping.items():
    358366            current = self
    class ImmutableList(tuple):  
    377385            ...
    378386        AttributeError: You cannot mutate this.
    379387    """
     388    __slots__ = ()
    380389
    381390    def __new__(cls, *args, **kwargs):
    382391        if 'warning' in kwargs:
    class DictWrapper(dict):  
    418427    Used by the SQL construction code to ensure that values are correctly
    419428    quoted before being used.
    420429    """
     430    __slots__ = ('func', 'prefix')
     431
    421432    def __init__(self, data, func, prefix):
    422433        super(DictWrapper, self).__init__(data)
    423434        self.func = func
  • django/django/utils/tree.py

    diff --git a/django/django/utils/tree.py b/django/django/utils/tree.py
    index 8894214..0fbc9b8 100644
    a b class Node(object):  
    1111    connection (the root) with the children being either leaf nodes or other
    1212    Node instances.
    1313    """
     14    __slots__ = ('children', 'connector', 'subtree_parents', 'negated')
     15
    1416    # Standard connector type. Clients usually won't use this at all and
    1517    # subclasses will usually override the value.
    1618    default = 'DEFAULT'
Back to Top