Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-3124

_WriteResult subclasses redefine "__acknowledged" slot

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 4.1
    • 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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            a.c.bovenberg@gmail.com Arie Bovenberg
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: