Skip to content

Conversation

cowo78
Copy link

@cowo78 cowo78 commented Sep 12, 2019

In case creating a list like Tree.children() does is too heavy for efficiency reasons.

Giuseppe Corbelli added 2 commits September 12, 2019 10:23
case an iterator is preferrable over a list creation for efficiency
reasons.
nodes as its companion method Tree.children().
@cowo78 cowo78 requested a review from caesar0301 as a code owner September 12, 2019 08:29
@caesar0301
Copy link
Owner

It seems as duplicated as method children which could convert into an iterator via iter(childrenI())

@cowo78
Copy link
Author

cowo78 commented Dec 2, 2019

Not really. Doing an iter(children()) would first create a list then iterate over it while children_itr() would just create the iterator. In the first case memory usage is O(N), in the second is O(1).

Return the children (Node) list of nid.
Empty list is returned if nid does not exist
"""
return [self[i] for i in self.is_branch(nid)]
Copy link

@crabhi crabhi Mar 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High, just a quick note - this method could now be implemented equivalently as list(self.children_itr(nid)). That might address @caesar0301's comment re. redundancy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants