From c425bfe08021be9b68fdfcdf67bb7daa63d38b27 Mon Sep 17 00:00:00 2001 From: Maddipatla Chatan Date: Tue, 15 Sep 2026 13:23:12 +0530 Subject: [PATCH] Optimize config merging in get_config method Refactor get_config method to use dict unpacking for merging. --- tensorflow_text/python/keras/layers/todense.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tensorflow_text/python/keras/layers/todense.py b/tensorflow_text/python/keras/layers/todense.py index 35eeebc60..df4e6dc4c 100644 --- a/tensorflow_text/python/keras/layers/todense.py +++ b/tensorflow_text/python/keras/layers/todense.py @@ -108,4 +108,8 @@ def get_config(self): 'shape': self._shape, } base_config = super(ToDense, self).get_config() - return dict(list(base_config.items()) + list(config.items())) + # Plain dict-merge instead of building two intermediate lists via + # list(...) + list(...) just to re-wrap them with dict(); same result + # (config's keys still take precedence on any overlap), no throwaway + # list allocations. + return {**base_config, **config}