Open Kiprey opened 1 year ago
Thanks for looking into this. Unfortunately, it seems that doing a proper deepcopy is too slow in practice (you can try python3 generator.py --output_dir test --no_of_files 100
with and without the patch, an order of magnitude difference). So currently it seems that the current solution is more usable in practice, despite its flaws :( Unless some custom solution is found for this case that gives us the best of both worlds.
Yes, it's really slow, and probably requires a lot of code structure changes, to get the generated content into a temporary context each time the _expand_rule function is executed, so that it can later decide whether to discard the currently generated content.
Classic python object shallow-copy problem.
When
RecursionError
is triggered, some of the generated lines are retained in the original context. This can lead to some unintended behavior, such as variable redefinition.