Skip to content

Conserve memory by using __slots__ instead of dicts #624

@sagivmalihi

Description

@sagivmalihi

Currently each document stores it's dict and also a dict stored in _data that holds a key-value mapping for all fields.

I suggest to replace dict with slots specifying only the necessary attributes, and replacing _data with a "strict dictionary" (that holds the keys once per class, and only values on each instance).

This will also have the added benefit of turning Documents (that are not DynamicDocuments) to strict classes (not allowing undeclared fields, thus preventing mistakes).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions