Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-02-28 07:37:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-02-28 07:37:24 +0300
commite09189cf50682016e69fb207b010447c3bc6471d (patch)
tree7d35a340741c282f79714be4ede58b5fd56e1ff1 /release/scripts/modules/bpy_types.py
parentea5664c0d17b8faa0385e9a46da4cd279e42d678 (diff)
complete lazy loading of py modules to use to a reduced set of pythons modules, gives ~40% speedup on cold & warm start (without netrender).
- use own OrderedDictMini class, pythons collections.OrderedDict is overkill, 179 sloc. replaced with own, 11 lines. - remove code which stored the class file & line per RNA subclass, this was useful but would raise its own exception every time to generate a stack trace to get the class info so we could use of the class failed to register. the class stores its module & name which can be enough to find where it was defined.
Diffstat (limited to 'release/scripts/modules/bpy_types.py')
-rw-r--r--release/scripts/modules/bpy_types.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py
index f7429474b06..f3daee49474 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -567,18 +567,15 @@ TypeMap = {}
class RNAMeta(type):
def __new__(cls, name, bases, classdict, **args):
result = type.__new__(cls, name, bases, classdict)
- if bases and bases[0] != StructRNA:
- import traceback
- import weakref
+ if bases and bases[0] is not StructRNA:
+ from _weakref import ref as ref
module = result.__module__
# first part of packages only
if "." in module:
module = module[:module.index(".")]
- sf = traceback.extract_stack(limit=2)[0]
-
- TypeMap.setdefault(module, []).append((weakref.ref(result), sf[0], sf[1]))
+ TypeMap.setdefault(module, []).append(ref(result))
return result
@@ -586,7 +583,20 @@ class RNAMeta(type):
def is_registered(cls):
return "bl_rna" in cls.__dict__
-import collections
+
+class OrderedDictMini(dict):
+ def __init__(self, *args):
+ self.order = []
+ dict.__init__(self, args)
+
+ def __setitem__(self, key, val):
+ dict.__setitem__(self, key, val)
+ if key not in self.order:
+ self.order.append(key)
+
+ def __delitem__(self, key):
+ dict.__delitem__(self, key)
+ self.order.remove(key)
class RNAMetaPropGroup(RNAMeta, StructMetaPropGroup):
@@ -600,7 +610,7 @@ class OrderedMeta(RNAMeta):
cls.order = list(attributes.keys())
def __prepare__(name, bases, **kwargs):
- return collections.OrderedDict()
+ return OrderedDictMini() # collections.OrderedDict()
# Only defined so operators members can be used by accessing self.order