Skip to content

Commit 40794fe

Browse files
committed
address review
1 parent e478cf7 commit 40794fe

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

doc/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ PyMongo 4.14 brings a number of changes including:
1010
- Added :meth:`pymongo.asynchronous.mongo_client.AsyncMongoClient.append_metadata` and
1111
:meth:`pymongo.mongo_client.MongoClient.append_metadata` to allow instantiated MongoClients to send client metadata
1212
on-demand
13+
- Improved performance of selecting a server with the Primary selector.
1314

1415
- Introduces a minor breaking change. When encoding :class:`bson.binary.BinaryVector`, a ``ValueError`` will be raised
1516
if the 'padding' metadata field is < 0 or > 7, or non-zero for any type other than PACKED_BIT.

pymongo/topology_description.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,7 @@ def apply_selector(
325325
return [description] if description else []
326326

327327
# Primary selection fast path.
328-
if self.topology_type == TOPOLOGY_TYPE.ReplicaSetWithPrimary and isinstance(
329-
selector, Primary
330-
):
328+
if self.topology_type == TOPOLOGY_TYPE.ReplicaSetWithPrimary and type(selector) is Primary:
331329
for sd in self._server_descriptions.values():
332330
if sd.server_type == SERVER_TYPE.RSPrimary:
333331
return [sd]

0 commit comments

Comments
 (0)