bartongroup / slivka

http://bartongroup.github.io/slivka/
Apache License 2.0
7 stars 3 forks source link

Change type of MongoDocuments to MutableMapping #87

Open warownia1 opened 4 years ago

warownia1 commented 4 years ago

By changing the type of MongoDocuments to slotted MutableMapping we can gain 2.3x performance boost at object creation and 4.7x less memory used compared to dict. All of that at the cost of some boilerplate code implementing item access and manipulation methods.

warownia1 commented 4 years ago

attr.s classes implementing MutableMapping are equally good

warownia1 commented 4 months ago

MutableMappings 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.

warownia1 commented 4 months ago

Related issue: https://github.com/mongomock/mongomock/issues/886

warownia1 commented 4 months ago

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.