caesar0301 / treelib

An efficient implementation of tree data structure in python 2/3.
http://treelib.readthedocs.io/en/latest/
Other
801 stars 185 forks source link

Nodes tree-wise bpointer/fpointers #120

Closed leonardbinet closed 4 years ago

leonardbinet commented 4 years ago

I encountered the following conditions:

The only solution I had was to create for each subtree a deepcopy, but it was very greedy and expensive in terms of memory.

This pull-request implements the ability to generate shallow copies of trees (no deep-copy of nodes), and mutate multiple shallow copies of the same tree without impacting other trees hierarchies.

I do so by assigning Nodes not a single _bpointer _fpointer, but one per shallow copy of tree.

leonardbinet commented 4 years ago

removed no-longer supported versions on python

Capture d’écran 2019-10-13 à 00 58 32
caesar0301 commented 4 years ago

Hi @leonardbinet , It is really a nice idea toget shallow copy of subtree. I was excited with your proposal in email before dealing with this pull request. However this implementation requires more consideration as it will break the compatibility I have been keeping for a long time. Dependencies from some existing projects invoking API bpointer and fpointer will be broken unexpectedly. Let's find out a more compatible version for this feature? Xiaming

alk-lbinet commented 4 years ago

@caesar0301 indeed I'll think about that

alk-lbinet commented 4 years ago

@caesar0301 I've updated PR to avoid any breaking change, + minor correction on __contains__ method (must return boolean)

alk-lbinet commented 4 years ago

hi @caesar0301, have you had time to have a look? thx in advance!

caesar0301 commented 4 years ago

@alk-lbinet Sorry for delayed response. Busy with some work. Could you give a merge into branch feature/tree-wise-node-pointer? I have some idea to try a tider and more unified API based on your improvement. Thanks!

leonardbinet commented 4 years ago

@caesar0301 I've created a PR on the feature/tree-wise-node-pointer branch (https://github.com/caesar0301/treelib/pull/126), but having no access on your repo I cannot merge though 🙂 , looking forward to seeing the unified API!

caesar0301 commented 4 years ago

@leonardbinet Thank you. Close this issue for now. Let's work on the new branch (#126 ) and Issue https://github.com/caesar0301/treelib/issues/127