From 179af89abbd155f6d6a02e078cd6cfa7f6a682bf Mon Sep 17 00:00:00 2001 From: Daniel Woste Date: Wed, 20 Sep 2023 17:16:52 +0200 Subject: [PATCH 1/3] removing deepcopy. --- docs/changelog.rst | 1 + sphinx_needs/directives/needpie.py | 4 ++-- sphinx_needs/filter_common.py | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index e42ef4984..1b4ab9367 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -23,6 +23,7 @@ Released: under development * Improvement: Suffix all warnings with ``[needs]``, and allow them to be suppressed (`#975 `_) * Improvement: :ref:`needextend` for single needs is much faster. +* Improvement: General performance improvement (up to 50%) and less memory consumption (~40%). 1.3.0 ----- diff --git a/sphinx_needs/directives/needpie.py b/sphinx_needs/directives/needpie.py index 08250f621..e10b37b3f 100644 --- a/sphinx_needs/directives/needpie.py +++ b/sphinx_needs/directives/needpie.py @@ -1,4 +1,3 @@ -import copy import os from typing import Iterable, List, Sequence @@ -156,7 +155,8 @@ def process_needpie(app: Sphinx, doctree: nodes.document, fromdocname: str, foun # execute filter_func code # Provides only a copy of needs to avoid data manipulations. context = { - "needs": copy.deepcopy(need_list), + # "needs": copy.deepcopy(need_list), + "needs": need_list, "results": [], } args = [] diff --git a/sphinx_needs/filter_common.py b/sphinx_needs/filter_common.py index a00795c56..9b5a661bc 100644 --- a/sphinx_needs/filter_common.py +++ b/sphinx_needs/filter_common.py @@ -4,7 +4,6 @@ """ from __future__ import annotations -import copy import re from types import CodeType from typing import Any, Iterable, TypeVar @@ -167,7 +166,8 @@ def process_filters( else: # Provides only a copy of needs to avoid data manipulations. context = { - "needs": copy.deepcopy(all_needs_incl_parts), + # "needs": copy.deepcopy(all_needs_incl_parts), + "needs": all_needs_incl_parts, "results": [], } From 39d854354692fee2892e1c791545e22e6696d731 Mon Sep 17 00:00:00 2001 From: Daniel Woste Date: Wed, 27 Sep 2023 15:09:08 +0200 Subject: [PATCH 2/3] Update sphinx_needs/directives/needpie.py Co-authored-by: Chris Sewell --- sphinx_needs/directives/needpie.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sphinx_needs/directives/needpie.py b/sphinx_needs/directives/needpie.py index e10b37b3f..5b2659f8e 100644 --- a/sphinx_needs/directives/needpie.py +++ b/sphinx_needs/directives/needpie.py @@ -155,7 +155,6 @@ def process_needpie(app: Sphinx, doctree: nodes.document, fromdocname: str, foun # execute filter_func code # Provides only a copy of needs to avoid data manipulations. context = { - # "needs": copy.deepcopy(need_list), "needs": need_list, "results": [], } From 650fc60180cdf96f8ba49433dc0349d7c5b0dff1 Mon Sep 17 00:00:00 2001 From: Daniel Woste Date: Wed, 27 Sep 2023 15:09:13 +0200 Subject: [PATCH 3/3] Update sphinx_needs/filter_common.py Co-authored-by: Chris Sewell --- sphinx_needs/filter_common.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sphinx_needs/filter_common.py b/sphinx_needs/filter_common.py index 9b5a661bc..5d68dff6c 100644 --- a/sphinx_needs/filter_common.py +++ b/sphinx_needs/filter_common.py @@ -166,7 +166,6 @@ def process_filters( else: # Provides only a copy of needs to avoid data manipulations. context = { - # "needs": copy.deepcopy(all_needs_incl_parts), "needs": all_needs_incl_parts, "results": [], }