Skip to content

Added entity instances caching. #291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 26, 2019
Prev Previous commit
Next Next commit
No need to wrap the classes that are not using the cache.
  • Loading branch information
jordanbriere committed Nov 25, 2019
commit 2aab39bad1457c94dfabec8a22e64df30f0e0104
7 changes: 5 additions & 2 deletions addons/source-python/packages/source-python/entities/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,13 @@ def __new__(metaclass, classname, bases, attributes, caching=True):
cls = super().__new__(
metaclass, classname, bases, attributes
)
# No need to override the instance creation/initialisation if we
# are not caching them
if not caching:
return cls

# New instances of this class will be cached in that dictionary
if caching:
metaclass.cache[cls] = {}
metaclass.cache[cls] = {}

def __init__(self, index):
# Does nothing, so we don't re-initialize cached instances, etc.
Expand Down