Skip to content

Commit facabc5

Browse files
committed
cqlengine: Remove deepcopy on UserType deserialization
This change makes it so newly instanced UserType during deserialization isn't immediately copied by deepcopy, which could cause huge slowdown if that UserType contains a lot of data or nested UserTypes, in which case the deepcopy calls would cascade as each to_python call would eventually clone parts of source object. As there isn't a lot of information on why this deepcopy is here in the first place this change could potentially break something. Running integration tests against this commit does not produce regressions, so this call looks safe to remove, but I'm leaving this warning here for the future reference. Fixes #152
1 parent 679ad24 commit facabc5

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

cassandra/cqlengine/columns.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,12 +1038,11 @@ def to_python(self, value):
10381038
if value is None:
10391039
return
10401040

1041-
copied_value = deepcopy(value)
10421041
for name, field in self.user_type._fields.items():
1043-
if copied_value[name] is not None or isinstance(field, BaseContainerColumn):
1044-
copied_value[name] = field.to_python(copied_value[name])
1042+
if value[name] is not None or isinstance(field, BaseContainerColumn):
1043+
value[name] = field.to_python(value[name])
10451044

1046-
return copied_value
1045+
return value
10471046

10481047
def to_database(self, value):
10491048
if value is None:

0 commit comments

Comments
 (0)