-
Type: Improvement
-
Resolution: Fixed
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: None
-
None
The following classes redefine the __acknowledged slot from the _WriteResult base:
BulkWriteResult
DeleteResult
InsertManyResult
InsertOneResult
UpdateResult
This wastes a bit of memory on each instance.
The Python docs say:
If a class defines a slot also defined in a base class, the instance variable defined by the base class slot is inaccessible (except by retrieving its descriptor directly from the base class). This renders the meaning of the program undefined. In the future, a check may be added to prevent this.
Solution is to remove the duplicate slot. If you agree, I'd like to submit a PR to fix this.
I see there have been several _slots_ issues in pymongo in the past. I discovered this slot issue with slotscheck, a tool I maintain. If you like, I can add it to CI as I've done for instagram/LibCST, sqlalchemy/sqlalchemy, and aio-libs/aiohttp.
- is related to
-
PYTHON-3141 Add slotscheck to pre-commit checks
- Closed