From 341f862569c56a69a6f5747048491d5e3f27d8db Mon Sep 17 00:00:00 2001 From: Matan Goldman Date: Sun, 7 Feb 2016 20:42:24 +0200 Subject: [PATCH] change the order of the elif inside to_dict for better performance (dictionary/additionalProperties is less probable) --- .../swagger-codegen/src/main/resources/python/model.mustache | 4 ++-- .../client/petstore/python/swagger_client/models/category.py | 4 ++-- samples/client/petstore/python/swagger_client/models/order.py | 4 ++-- samples/client/petstore/python/swagger_client/models/pet.py | 4 ++-- samples/client/petstore/python/swagger_client/models/tag.py | 4 ++-- samples/client/petstore/python/swagger_client/models/user.py | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/python/model.mustache b/modules/swagger-codegen/src/main/resources/python/model.mustache index f14a121aef9..bd33a997c3e 100644 --- a/modules/swagger-codegen/src/main/resources/python/model.mustache +++ b/modules/swagger-codegen/src/main/resources/python/model.mustache @@ -95,14 +95,14 @@ class {{classname}}(object): lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() elif isinstance(value, dict): result[attr] = dict(map( lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, value.items() )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() else: result[attr] = value diff --git a/samples/client/petstore/python/swagger_client/models/category.py b/samples/client/petstore/python/swagger_client/models/category.py index 9f66c3e6764..b8d540c51bd 100644 --- a/samples/client/petstore/python/swagger_client/models/category.py +++ b/samples/client/petstore/python/swagger_client/models/category.py @@ -106,14 +106,14 @@ class Category(object): lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() elif isinstance(value, dict): result[attr] = dict(map( lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, value.items() )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() else: result[attr] = value diff --git a/samples/client/petstore/python/swagger_client/models/order.py b/samples/client/petstore/python/swagger_client/models/order.py index b2b490ddfda..4c8911f267b 100644 --- a/samples/client/petstore/python/swagger_client/models/order.py +++ b/samples/client/petstore/python/swagger_client/models/order.py @@ -212,14 +212,14 @@ class Order(object): lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() elif isinstance(value, dict): result[attr] = dict(map( lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, value.items() )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() else: result[attr] = value diff --git a/samples/client/petstore/python/swagger_client/models/pet.py b/samples/client/petstore/python/swagger_client/models/pet.py index a568235a492..dfa614b1e9b 100644 --- a/samples/client/petstore/python/swagger_client/models/pet.py +++ b/samples/client/petstore/python/swagger_client/models/pet.py @@ -212,14 +212,14 @@ class Pet(object): lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() elif isinstance(value, dict): result[attr] = dict(map( lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, value.items() )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() else: result[attr] = value diff --git a/samples/client/petstore/python/swagger_client/models/tag.py b/samples/client/petstore/python/swagger_client/models/tag.py index 293b13f51ad..50f829d65e3 100644 --- a/samples/client/petstore/python/swagger_client/models/tag.py +++ b/samples/client/petstore/python/swagger_client/models/tag.py @@ -106,14 +106,14 @@ class Tag(object): lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() elif isinstance(value, dict): result[attr] = dict(map( lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, value.items() )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() else: result[attr] = value diff --git a/samples/client/petstore/python/swagger_client/models/user.py b/samples/client/petstore/python/swagger_client/models/user.py index 6a161d8cbbf..fd6d16824b3 100644 --- a/samples/client/petstore/python/swagger_client/models/user.py +++ b/samples/client/petstore/python/swagger_client/models/user.py @@ -256,14 +256,14 @@ class User(object): lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() elif isinstance(value, dict): result[attr] = dict(map( lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, value.items() )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() else: result[attr] = value