Skip to content

Commit 1e5b801

Browse files
committed
improve cache of classes
1 parent 51aa135 commit 1e5b801

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

python/pyspark/sql.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,10 +674,15 @@ def _restore_object(dataType, obj):
674674
# use id(dataType) as key to speed up lookup in dict
675675
# Because of batched pickling, dataType will be the
676676
# same object in mose cases.
677-
cls = _cached_cls.get(id(dataType))
677+
k = id(dataType)
678+
cls = _cached_cls.get(k)
678679
if cls is None:
679-
cls = _create_cls(dataType)
680-
_cached_cls[id(dataType)] = cls
680+
# use dataType as key to avoid create multiple class
681+
cls = _cached_cls.get(dataType)
682+
if cls is None:
683+
cls = _create_cls(dataType)
684+
_cached_cls[dataType] = cls
685+
_cached_cls[k] = cls
681686
return cls(obj)
682687

683688

0 commit comments

Comments
 (0)