@@ -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