Skip to content

Commit

Permalink
[Python] [Performance] Avoid unnessacary checks inside the loop (#4305)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arun authored and wing328 committed Nov 7, 2019
1 parent 9bfea4b commit 649eab2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -629,11 +629,11 @@ class ApiClient(object):
return data

kwargs = {}
if klass.openapi_types is not None:
if (data is not None and
klass.openapi_types is not None and
isinstance(data, (list, dict))):
for attr, attr_type in six.iteritems(klass.openapi_types):
if (data is not None and
klass.attribute_map[attr] in data and
isinstance(data, (list, dict))):
if klass.attribute_map[attr] in data:
value = data[klass.attribute_map[attr]]
kwargs[attr] = self.__deserialize(value, attr_type)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -622,11 +622,11 @@ def __deserialize_model(self, data, klass):
return data

kwargs = {}
if klass.openapi_types is not None:
if (data is not None and
klass.openapi_types is not None and
isinstance(data, (list, dict))):
for attr, attr_type in six.iteritems(klass.openapi_types):
if (data is not None and
klass.attribute_map[attr] in data and
isinstance(data, (list, dict))):
if klass.attribute_map[attr] in data:
value = data[klass.attribute_map[attr]]
kwargs[attr] = self.__deserialize(value, attr_type)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,11 +624,11 @@ def __deserialize_model(self, data, klass):
return data

kwargs = {}
if klass.openapi_types is not None:
if (data is not None and
klass.openapi_types is not None and
isinstance(data, (list, dict))):
for attr, attr_type in six.iteritems(klass.openapi_types):
if (data is not None and
klass.attribute_map[attr] in data and
isinstance(data, (list, dict))):
if klass.attribute_map[attr] in data:
value = data[klass.attribute_map[attr]]
kwargs[attr] = self.__deserialize(value, attr_type)

Expand Down
8 changes: 4 additions & 4 deletions samples/client/petstore/python/petstore_api/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,11 +622,11 @@ def __deserialize_model(self, data, klass):
return data

kwargs = {}
if klass.openapi_types is not None:
if (data is not None and
klass.openapi_types is not None and
isinstance(data, (list, dict))):
for attr, attr_type in six.iteritems(klass.openapi_types):
if (data is not None and
klass.attribute_map[attr] in data and
isinstance(data, (list, dict))):
if klass.attribute_map[attr] in data:
value = data[klass.attribute_map[attr]]
kwargs[attr] = self.__deserialize(value, attr_type)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -622,11 +622,11 @@ def __deserialize_model(self, data, klass):
return data

kwargs = {}
if klass.openapi_types is not None:
if (data is not None and
klass.openapi_types is not None and
isinstance(data, (list, dict))):
for attr, attr_type in six.iteritems(klass.openapi_types):
if (data is not None and
klass.attribute_map[attr] in data and
isinstance(data, (list, dict))):
if klass.attribute_map[attr] in data:
value = data[klass.attribute_map[attr]]
kwargs[attr] = self.__deserialize(value, attr_type)

Expand Down

0 comments on commit 649eab2

Please sign in to comment.