You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, thanks a lot for this library : it is very useful !
Recently at my company we wanted to update to treelib 1.6.1, however we started to have problems
because now everything stored in the tree has to be "picklable", because of the use of copy.deepcopy in the clone_pointers method.
Why using deepcopy, in this case ? 1) I think it is rather inefficient, 2) it really puts an additional constraint on the kind of object in the fpointer list, which was not there before
According to the comment in the corresponding code, this is done to not pass the fpointers list as a reference.
Then, would you consider using shallow copy instead of deepcopy ?
Proposal:
diff --git a/treelib/node.py b/treelib/node.py index 6accae1..910d2e2 100644 --- a/treelib/node.py +++ b/treelib/node.py @@ -217,7 +217,7 @@ class Node(object):
self.set_predecessor(former_bpointer, new_tree_id)
former_fpointer = self.successors(former_tree_id)
# fpointer is a list and would be copied by reference without deepcopy
- self.set_successors(copy.deepcopy(former_fpointer), tree_id=new_tree_id)
+ self.set_successors(list(former_fpointer), tree_id=new_tree_id)
def reset_pointers(self, tree_id):
self.set_predecessor(None, tree_id)
The text was updated successfully, but these errors were encountered:
First of all, thanks a lot for this library : it is very useful !
Recently at my company we wanted to update to treelib 1.6.1, however we started to have problems
because now everything stored in the tree has to be "picklable", because of the use of
copy.deepcopy
in theclone_pointers
method.Why using
deepcopy
, in this case ? 1) I think it is rather inefficient, 2) it really puts an additional constraint on the kind of object in thefpointer
list, which was not there beforeAccording to the comment in the corresponding code, this is done to not pass the fpointers list as a reference.
Then, would you consider using shallow copy instead of deepcopy ?
Proposal:
The text was updated successfully, but these errors were encountered: