From a6cf53ae58acffacf440b91d95fe068b6ca218c6 Mon Sep 17 00:00:00 2001 From: Ofek Azarya Date: Wed, 28 Jan 2026 15:34:06 +0200 Subject: [PATCH 1/2] Test no deep copies and less flattens --- easypy/logging/_logbook.py | 4 ++-- easypy/threadtree.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/easypy/logging/_logbook.py b/easypy/logging/_logbook.py index 2eabd02..0657db2 100644 --- a/easypy/logging/_logbook.py +++ b/easypy/logging/_logbook.py @@ -227,10 +227,10 @@ def process(self, record): if extra is not None: decoration = extra.pop('decoration', decoration) - contexts = THREAD_LOGGING_CONTEXT.context extra = THREAD_LOGGING_CONTEXT.flatten() - extra['context'] = "[%s]" % ";".join(contexts) if contexts else "" + contexts = extra['context'] record.extra.update(extra) + record.extra['context'] = "[%s]" % ";".join(contexts) if contexts else "" indentation = record.extra['indentation'] indents = chain(repeat(G.graphics.INDENT_SEGMENT, indentation), repeat(decoration, 1)) diff --git a/easypy/threadtree.py b/easypy/threadtree.py index 7e84eaa..446e31a 100644 --- a/easypy/threadtree.py +++ b/easypy/threadtree.py @@ -487,7 +487,7 @@ def _get_context_data(self, thread_uuid=None, combined=False): parent_uuid = get_parent_uuid(thread_uuid) if parent_uuid: parent_ctx = self._get_context_data(parent_uuid, combined=True) - ctx = deepcopy(parent_ctx) + ctx + ctx = parent_ctx + ctx return ctx def get(self, k, default=None): From f1fa55f41decd1dfbddd5ec23a22ed6f6d7cd37a Mon Sep 17 00:00:00 2001 From: Ofek Azarya Date: Wed, 28 Jan 2026 16:15:37 +0200 Subject: [PATCH 2/2] when caching avoid using inspect for faster operation --- easypy/caching.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/easypy/caching.py b/easypy/caching.py index f29bbca..7463820 100644 --- a/easypy/caching.py +++ b/easypy/caching.py @@ -181,6 +181,10 @@ class _CachedException(tuple): pass +def _default_key_func(*args, **kwargs): + return _make_key(args, kwargs, False) + + class _TimeCache(DecoratingDescriptor): def __init__(self, func, **kwargs): @@ -196,8 +200,7 @@ def __init__(self, func, **kwargs): key_func = kwargs['key_func'] if not key_func: - def key_func(*args, **kwargs): - return _make_key(args, kwargs, False) + key_func = _default_key_func self._key_func = key_func self.NOT_FOUND = object() @@ -210,7 +213,11 @@ def key_func(*args, **kwargs): def make_key(self, args, kwargs): bound = self.sig.bind(*args, **kwargs) _apply_defaults(bound) - return kwargs_resilient(self._key_func)(**bound.arguments) + + if self._key_func is _default_key_func: + return self._key_func(**bound.arguments) + else: + return kwargs_resilient(self._key_func)(**bound.arguments) def key_func(self, func): """