Skip to content

Commit d9ed32e

Browse files
committed
Return self if no changes
1 parent 6ece40f commit d9ed32e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

temporalio/converter.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,6 @@ async def decode_failure(
13291329
return self.failure_converter.from_failure(failure, self.payload_converter)
13301330

13311331
def _with_context(self, context: SerializationContext) -> Self:
1332-
cloned = dataclasses.replace(self)
13331332
payload_converter = self.payload_converter
13341333
payload_codec = self.payload_codec
13351334
failure_converter = self.failure_converter
@@ -1339,6 +1338,16 @@ def _with_context(self, context: SerializationContext) -> Self:
13391338
payload_codec = payload_codec.with_context(context)
13401339
if isinstance(failure_converter, WithSerializationContext):
13411340
failure_converter = failure_converter.with_context(context)
1341+
if all(
1342+
new == orig
1343+
for new, orig in [
1344+
(payload_converter, self.payload_converter),
1345+
(payload_codec, self.payload_codec),
1346+
(failure_converter, self.failure_converter),
1347+
]
1348+
):
1349+
return self
1350+
cloned = dataclasses.replace(self)
13421351
object.__setattr__(cloned, "payload_converter", payload_converter)
13431352
object.__setattr__(cloned, "payload_codec", payload_codec)
13441353
object.__setattr__(cloned, "failure_converter", failure_converter)

0 commit comments

Comments
 (0)