I want to store a value in a dict (to behave like a cache) but I care about performances. I wonder if it is better to create a second variable in order to store the result of the sum compared to retrieving the value from the dict where the result is already stored.

Real code:

```py
@property
def total_stats(self) -> Statistics:
    if self.items in self.__total_stat:
        return self.__total_stat[self.items]
    self.__total_stat[self.__total_stat] = \
        (res := sum((item.stats for item in self.items), Statistics()))
    return res

```

I use this function in order to sum the statistics for a list of items as a `Statistics` object, and I want to know what is the best option between a second assignment or get a value in a dict.

Sharing the rest of the class or anything else isn't necessary; the dict behaves like a cache without limits, and the sum creates a `Statistics` object, but that's not the point of the question.