Open warownia1 opened 4 years ago
attr.s classes implementing MutableMapping are equally good
MutableMapping
s which are not dicts seem to not work with mongomock.
Inserted items are stored as Python objects directly and not converted to json/bson
Collection.find()
is unable to find them if filters are provided.
Related issue: https://github.com/mongomock/mongomock/issues/886
All tests green when using real mongo database in tests Adjusting code to work with mongomock undoes all benefits gained from switching to slotted classes.
By changing the type of
MongoDocument
s to slottedMutableMapping
we can gain 2.3x performance boost at object creation and 4.7x less memory used compared todict
. All of that at the cost of some boilerplate code implementing item access and manipulation methods.