From 724027d134a2b20e9b573d5e02ac1d0f23ab2e82 Mon Sep 17 00:00:00 2001 From: Griatch Date: Thu, 2 Aug 2012 17:03:26 +0200 Subject: [PATCH] Optimizations: Removed unnecessary lookups when comparing objects with the = operator (used a lot in moving and messaging) --- src/objects/objects.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/objects/objects.py b/src/objects/objects.py index 9586038dbf..30eb8bc7ad 100644 --- a/src/objects/objects.py +++ b/src/objects/objects.py @@ -19,6 +19,10 @@ from src.typeclasses.typeclass import TypeClass from src.commands import cmdset, command __all__ = ("Object", "Character", "Room", "Exit") +_GA = object.__getattribute__ +_SA = object.__setattr__ +_DA = object.__delattr__ + # # Base class to inherit from. # @@ -358,11 +362,13 @@ class Object(TypeClass): parent doesn't work. """ try: - return self.dbref == other or self.dbref == other.dbref + return _GA(self, "dbid") == other \ + or _GA(self, "dbid") == _GA(other, "dbid") except AttributeError: # compare players instead try: - return self.player.uid == other or self.player.uid == other.player.uid + return _GA(_GA(self, "player"),"uid") == other \ + or _GA(_GA(self, "player"),"uid") == _GA(_GA(other, "player"),"uid") except AttributeError: return False