Commit 04e0db00 authored by j-mark-hou's avatar j-mark-hou Committed by Guolin Ke
Browse files

now use set instead of list in python package basic.Dataset.get_ref_chain (#758)

parent 399710ac
...@@ -1185,17 +1185,17 @@ class Dataset(object): ...@@ -1185,17 +1185,17 @@ class Dataset(object):
chain of references of self : set of Dataset objects chain of references of self : set of Dataset objects
''' '''
head = self head = self
ref_chain = [] ref_chain = set()
while len(ref_chain) < ref_limit: while len(ref_chain) < ref_limit:
if isinstance(head, Dataset): if isinstance(head, Dataset):
ref_chain += [head] ref_chain.add(head)
if (head.reference is not None) and (head.reference not in ref_chain): if (head.reference is not None) and (head.reference not in ref_chain):
head = head.reference head = head.reference
else: else:
break break
else: else:
break break
return(set(ref_chain)) return(ref_chain)
class Booster(object): class Booster(object):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment