Skip to content

Commit

Permalink
improve cache of classes
Browse files Browse the repository at this point in the history
  • Loading branch information
davies committed Aug 1, 2014
1 parent 51aa135 commit 1e5b801
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions python/pyspark/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,10 +674,15 @@ def _restore_object(dataType, obj):
# use id(dataType) as key to speed up lookup in dict
# Because of batched pickling, dataType will be the
# same object in mose cases.
cls = _cached_cls.get(id(dataType))
k = id(dataType)
cls = _cached_cls.get(k)
if cls is None:
cls = _create_cls(dataType)
_cached_cls[id(dataType)] = cls
# use dataType as key to avoid create multiple class
cls = _cached_cls.get(dataType)
if cls is None:
cls = _create_cls(dataType)
_cached_cls[dataType] = cls
_cached_cls[k] = cls
return cls(obj)


Expand Down

0 comments on commit 1e5b801

Please sign in to comment.