@@ -792,6 +792,16 @@ def from_table(cls, domain, source, row_indices=...):
792
792
:return: a new table
793
793
:rtype: Orange.data.Table
794
794
"""
795
+ if domain is source .domain :
796
+ table = cls .from_table_rows (source , row_indices )
797
+ # assure resulting domain is the instance passed on input
798
+ table .domain = domain
799
+ # since sparse flags are not considered when checking for
800
+ # domain equality, fix manually.
801
+ with table .unlocked_reference ():
802
+ table = assure_domain_conversion_sparsity (table , source )
803
+ return table
804
+
795
805
new_cache = _thread_local .conversion_cache is None
796
806
try :
797
807
if new_cache :
@@ -801,15 +811,6 @@ def from_table(cls, domain, source, row_indices=...):
801
811
cached = _idcache_restore (_thread_local .conversion_cache , (domain , source ))
802
812
if cached is not None :
803
813
return cached
804
- if domain is source .domain :
805
- table = cls .from_table_rows (source , row_indices )
806
- # assure resulting domain is the instance passed on input
807
- table .domain = domain
808
- # since sparse flags are not considered when checking for
809
- # domain equality, fix manually.
810
- with table .unlocked_reference ():
811
- table = assure_domain_conversion_sparsity (table , source )
812
- return table
813
814
814
815
# avoid boolean indices; also convert to slices if possible
815
816
row_indices = _optimize_indices (row_indices , len (source ))
@@ -834,7 +835,9 @@ def from_table(cls, domain, source, row_indices=...):
834
835
self .W = source .W [row_indices ]
835
836
self .name = getattr (source , 'name' , '' )
836
837
self .ids = source .ids [row_indices ]
837
- self .attributes = deepcopy (getattr (source , 'attributes' , {}))
838
+ self .attributes = getattr (source , 'attributes' , {})
839
+ if new_cache : # only deepcopy attributes for the outermost transformation
840
+ self .attributes = deepcopy (self .attributes )
838
841
_idcache_save (_thread_local .conversion_cache , (domain , source ), self )
839
842
return self
840
843
finally :
@@ -879,6 +882,7 @@ def from_table_rows(cls, source, row_indices):
879
882
:return: a new table
880
883
:rtype: Orange.data.Table
881
884
"""
885
+ is_outermost_transformation = _thread_local .conversion_cache is None
882
886
self = cls ()
883
887
self .domain = source .domain
884
888
with self .unlocked_reference ():
@@ -892,7 +896,9 @@ def from_table_rows(cls, source, row_indices):
892
896
self .W = source .W [row_indices ]
893
897
self .name = getattr (source , 'name' , '' )
894
898
self .ids = source .ids [row_indices ]
895
- self .attributes = deepcopy (getattr (source , 'attributes' , {}))
899
+ self .attributes = getattr (source , 'attributes' , {})
900
+ if is_outermost_transformation :
901
+ self .attributes = deepcopy (self .attributes )
896
902
return self
897
903
898
904
@classmethod
0 commit comments