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

_WriteResult subclasses redefine "__acknowledged" slot

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor - P4
    • Resolution: Fixed
    • None
    • 4.1
    • None
    • None

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: