Skip to content

Commit a7cab51

Browse files
Davidrjxwojcikstefan
authored andcommitted
Use a set literal in _clean_settings (#1585)
1 parent a8d6e59 commit a7cab51

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,3 +243,4 @@ that much better:
243243
* Victor Varvaryuk
244244
* Stanislav Kaledin (https://github.com/sallyruthstruik)
245245
* Dmitry Yantsen (https://github.com/mrTable)
246+
* Renjianxin (https://github.com/Davidrjx)

mongoengine/connection.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,14 @@ def get_connection(alias=DEFAULT_CONNECTION_NAME, reconnect=False):
146146
raise MongoEngineConnectionError(msg)
147147

148148
def _clean_settings(settings_dict):
149-
irrelevant_fields = set([
150-
'name', 'username', 'password', 'authentication_source',
151-
'authentication_mechanism'
152-
])
149+
# set literal more efficient than calling set function
150+
irrelevant_fields_set = {
151+
'name', 'username', 'password',
152+
'authentication_source', 'authentication_mechanism'
153+
}
153154
return {
154155
k: v for k, v in settings_dict.items()
155-
if k not in irrelevant_fields
156+
if k not in irrelevant_fields_set
156157
}
157158

158159
# Retrieve a copy of the connection settings associated with the requested

0 commit comments

Comments
 (0)