added __slots__ to BaseDocument and Document

changed the _data field to static key-value mapping instead of hash table
This implements #624
This commit is contained in:
Sagiv Malihi
2014-04-03 12:38:33 +03:00
committed by Sagiv Malihi
parent bcbe740598
commit 9835b382da
4 changed files with 243 additions and 14 deletions

View File

@@ -52,16 +52,17 @@ class EmbeddedDocument(BaseDocument):
`_cls` set :attr:`allow_inheritance` to ``False`` in the :attr:`meta`
dictionary.
"""
__slots__ = ('_instance')
# The __metaclass__ attribute is removed by 2to3 when running with Python3
# my_metaclass is defined so that metaclass can be queried in Python 2 & 3
my_metaclass = DocumentMetaclass
__metaclass__ = DocumentMetaclass
_instance = None
def __init__(self, *args, **kwargs):
super(EmbeddedDocument, self).__init__(*args, **kwargs)
self._instance = None
self._changed_fields = []
def __eq__(self, other):
@@ -124,6 +125,8 @@ class Document(BaseDocument):
my_metaclass = TopLevelDocumentMetaclass
__metaclass__ = TopLevelDocumentMetaclass
__slots__ = ('__objects' )
def pk():
"""Primary key alias
"""