Skip to content

Commit

Permalink
Merge pull request #482 from uyha/skip-same-type
Browse files Browse the repository at this point in the history
skip conversion if the object is already the correct type
  • Loading branch information
yukinarit authored Mar 3, 2024
2 parents 35901de + 0b453e2 commit 769fbbd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions serde/de.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,11 @@ def from_obj(c: Type[T], o: Any, named: bool, reuse_instances: Optional[bool]) -

res: Any

# It is possible that the parser already generates the correct data type requested
# by the caller. Hence, it should be checked early to avoid doing anymore work.
if type(o) is c:
return o

def deserializable_to_obj(cls: Type[T]) -> T:
serde_scope: Scope = getattr(cls, SERDE_SCOPE)
func_name = FROM_DICT if named else FROM_ITER
Expand Down

0 comments on commit 769fbbd

Please sign in to comment.