Skip to content

Commit

Permalink
Merge pull request #62 from scrapy/performance
Browse files Browse the repository at this point in the history
Improve performance
  • Loading branch information
kmike authored May 12, 2022
2 parents 60c9ccc + 8733014 commit 8f239bc
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions itemadapter/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,17 @@ def __init__(self, item: Any) -> None:

@classmethod
def is_item(cls, item: Any) -> bool:
return any(adapter_class.is_item(item) for adapter_class in cls.ADAPTER_CLASSES)
for adapter_class in cls.ADAPTER_CLASSES:
if adapter_class.is_item(item):
return True
return False

@classmethod
def is_item_class(cls, item_class: type) -> bool:
return any(
adapter_class.is_item_class(item_class) for adapter_class in cls.ADAPTER_CLASSES
)
for adapter_class in cls.ADAPTER_CLASSES:
if adapter_class.is_item_class(item_class):
return True
return False

@classmethod
def get_field_meta_from_class(cls, item_class: type, field_name: str) -> MappingProxyType:
Expand Down

0 comments on commit 8f239bc

Please sign in to comment.