Skip to content

Commit ada371e

Browse files
committed
Table.from_table: refactor: separate cache-independent part
1 parent c69082b commit ada371e

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

Orange/data/table.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,16 @@ def from_table(cls, domain, source, row_indices=...):
792792
:return: a new table
793793
:rtype: Orange.data.Table
794794
"""
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+
795805
new_cache = _thread_local.conversion_cache is None
796806
try:
797807
if new_cache:
@@ -801,17 +811,6 @@ def from_table(cls, domain, source, row_indices=...):
801811
cached = _idcache_restore(_thread_local.conversion_cache, (domain, source))
802812
if cached is not None:
803813
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-
if new_cache: # from_table_rows is not outermost: explicitly deepcopy attributes
813-
table.attributes = deepcopy(getattr(source, 'attributes', {}))
814-
return table
815814

816815
# avoid boolean indices; also convert to slices if possible
817816
row_indices = _optimize_indices(row_indices, len(source))

0 commit comments

Comments
 (0)